在JavaScript中解析嵌套的json
问题描述:
这是我在JavaScript中的json响应。在JavaScript中解析嵌套的json
{"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"}}
我解析这个JSON,但它没有给出正确的输出。
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.
}
感谢
目前还不清楚你在这里问什么。你在说什么阵列?另外,你给的'json response'已经被解析了,如果你想迭代它,那么检查一下:http://*.com/questions/14379274/javascript-iterate-object和http://*.com/questions/8312459/iterate-through-object-properties将来一定要更具体的在你的问题中 – 2014-11-14 13:47:30
是的,我想迭代这个响应并添加到数组中。 – Kumar 2014-11-15 08:25:32
然后,从我上次评论的两个问题链接应该帮助你 – 2014-11-15 11:07:02