Geek
Geek

Reputation: 1344

JSON Parse in AngularJS

I have a JSON Object returned from server.

{
  "SOAP-ENV:Envelope": {
    "SOAP-ENV:Body": {
      "ADDWEBSOperationResponse": {
        "Num1": 10,
        "Result": 20,
        "Num2": 10,
        "xmlns": "http://www.**.**.Response.com"
      }
    },
    "xmlns:SOAP-ENV": "http://schemas.xmlsoap.org/soap/envelope/",
    "xmlns:soapenv": "http://schemas.xmlsoap.org/soap/envelope/",
    "xmlns:add": "http://www.**.**.Request.com"
  }
}

I wanted to print Result in my page. I was trying with data.Resultbut its not displaying the value.

Upvotes: 2

Views: 245

Answers (4)

Setily
Setily

Reputation: 822

data["SOAP-ENV:Envelope"]["SOAP-ENV:Body"]["ADDWEBSOperationResponse"].Result

Upvotes: 1

Shubham Khatri
Shubham Khatri

Reputation: 281626

I should be

data["SOAP-ENV:Envelope"]["SOAP-ENV:Body"]["ADDWEBSOperationResponse"].Result

You need to follow the hierarchy.

JSFIDDLE

Upvotes: 1

Vivek Pratap Singh
Vivek Pratap Singh

Reputation: 9974

Use bracket notation as it is particularly useful for non-identifier-safe characters and also for accessing keys that you may not know ahead of time

data["SOAP-ENV:Envelope"]["SOAP-ENV:Body"]["ADDWEBSOperationResponse"]["Result"]

Upvotes: 4

DAXaholic
DAXaholic

Reputation: 35338

Try it with

data['SOAP-ENV:Envelope']['SOAP-ENV:Body']['ADDWEBSOperationResponse'].Result

Upvotes: 3

Related Questions