Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

AngularJS : Parsing JSON Object inside AngularJS controller

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am using AngualrJS and via factory call getting a response and it returns a JSON object.
{"0":"Sample_IS_Action.xml","1":"Sample_IS_Action_123.xml","2":"Sample_SOAP_Action.xml","3":"Sample_SOAP_IS_Action.xml"}
But inside my controller i am not able to retrieve the data entries as it gives Object,object.

Please suggest how to parse the JSON object to get the values
Sample_IS_Action.xml
Sample_IS_Action_123.xml
Sample_SOAP_Action.xml
Sample_SOAP_IS_Action.xml

Thanks,
Faraz
 
Sheriff
Posts: 67651
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure what the problem is. The parsed JSON will indeed be an object. What else were you expecting? Or are you saying that the JSON is still in String format?

 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Faraz Ka wrote:I am using AngualrJS and via factory call getting a response and it returns a JSON object. ... But inside my controller i am not able to retrieve the data entries as it gives Object,object


  • In order to stay independent of the browser implementation of the window JSON object, JSON objects are serialized in AngularJS with angular.toJson.
  • JSON strings are de-serialized with angular.fromJson.
  • A JSON object de-serialized with JSON.parse isn't necessarily of type "JSON" - so Object.prototype.toString.call(jsonObject) will return "[object Object]" rather than "[object JSON]".

  •  
    reply
      Bookmark Topic Watch Topic
    • New Topic