9

I am receiving back from the server a JSON string like this one:

[ { "Title": "Windows", "URL": "http:\/\/www.domain.com\/soft\/", "Type": "out", "Price": "140" } ] 

I save it into a variable string and I am trying to convert it to a JSON object like this:

const json = JSON.parse(string); 

After that I get the Object which looks great:

[Object] ->Title: "Windows" ->URL: "http:www.domain.com/soft/" ->Type: "out" ->Price: "140" ->__proto__: Object 

but when I try to access it using for example json.Price I get undefined, any idea what I'm missing here?

1
  • Please post a small example that reproduces the problem. Chances are you simply have a typo or mis-assigned variable somewhere. Commented Aug 29, 2011 at 8:26

1 Answer 1

17

As you wrap your content with [] you get an array with one object. So this should work:

json[0].Price 

But you can also remove the brackets.

Sign up to request clarification or add additional context in comments.

1 Comment

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.