这是我的JSON:遍历JSON结果和排序按数字顺序
{"event": {
"items": [
{"position": "2", "name": "John Doe 1"},
{"position" : "1", "name": "John Doe 2"},
{"position": "3", "name": "John Does 3"}
]
}
这是我如何遍历结果读取JSON结果后:
$.each(data.event.items, function(val) {
$('#list').append('<li>'+data.event.items[val].name+'</li>');
});
现在的顺序是: John Doe 1,John Doe 2,John Doe 3.我想循环它们并按照已经给出的位置顺序显示它们。所以正确的命令是John Doe 2,John Doe 1,John Doe 3.
我该如何实现这个目标?
谢谢你,这是一个简单的答案,我wounder我没有想到这样的事情我自己。我简化了我的代码,这是JSON ... – 2013-04-04 07:10:57