-2

This is my json response in javascript.

{"1": {"11": "51","12": "52","13": "53","14": "54","15": "55"},"2": {"11": "51","12": "52","13": "53","14":"54","15": "55"},"4": {"11": "51","12": "52","13": "53","14": "54","15": "55"}}

I am parsing this json but it is not giving proper output.

for(var i=0; i<Object.keys(obj).length; i++)
{
  // here how should i parse the json and get all the key and values into the array.
}

Thanks

Kumar
  • 442
  • 1
  • 9
  • 19
  • it's not clear what you're asking here.. what array are you talking about? also, the `json response` you gave is already parsed, and if you want to iterate that then check these out: http://stackoverflow.com/questions/14379274/javascript-iterate-object and http://stackoverflow.com/questions/8312459/iterate-through-object-properties in the future be sure to be more specific in your questions – Nitzan Tomer Nov 14 '14 at 13:47
  • Yes, i want to iterate this response and add into a array. – Kumar Nov 15 '14 at 08:25
  • Then the two question links from my last comment should help you out – Nitzan Tomer Nov 15 '14 at 11:07

1 Answers1

0

There's a native way of parsing JSON in Javascript which is JSON.parse(yourString).

Were you not aware of it or are you trying to create your own parser?

sebagomez
  • 9,501
  • 7
  • 51
  • 89