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 stringand I am trying to convert it to a JSON object like this:

var json = JSON.parse(string);

after that I get the Object which looks great:

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

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

Tsundoku
  • 9,104
  • 29
  • 93
  • 127
  • Please post a small example that reproduces the problem. Chances are you simply have a typo or mis-assigned variable somewhere. – phihag Aug 29 '11 at 08:26

1 Answers1

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.

Andreas Köberle
  • 106,652
  • 57
  • 273
  • 297