迭代JavaScript JSON对象 - Chrome / Opera下一步反向 - FireFox / Safari确定 [英] Iterate JavaScript JSON Object - Chrome / Opera Next reverse - FireFox / Safari OK
问题描述
观看数字的顺序。
JSON例子:
< pre $ {
3259341:{
datum:2013-07-23 14:55:00,
titel: Open Space
},
3259609:{
datum:2013-07-23 14:50:00,
titel:Something否则
,
3257403:{
datum:2013-07-23 14:45:00,
titel:High-Tech
}
如果我尝试迭代JSON对象使用Chrome或Opera Next(WebKit)
for in将在JSON属性上反向运行。 FireFox或Safari(桌面或iOS)正确运行,正确的顺序。
有没有像预期一样的方式,像FireFox吗? JSON对象是无序的名称/值对集合,你不能(也不应该)依赖任何特定的元素顺序。
First have a look here, with Google Chrome and then FireFox: http://jsbin.com/aherar/1/edit Watch the order of the numbers.
JSON example:
{
"3259341": {
"datum": "2013-07-23 14:55:00",
"titel": "Open Space"
},
"3259609": {
"datum": "2013-07-23 14:50:00",
"titel": "Something else"
},
"3257403": {
"datum": "2013-07-23 14:45:00",
"titel": "High-Tech"
}
}
If I try to iterate over the JSON-Object with Chrome or Opera Next (WebKit) the "for in" runs reverse over the JSON properties. FireFox or Safari (Desktop or iOS) runs correctly, right order.
Is there a way to do it like expected, like FireFox do?
JSON objects are unordered sets of name/value pairs, you can't (and shouldn't!) rely on any certain order of elements.
这篇关于迭代JavaScript JSON对象 - Chrome / Opera下一步反向 - FireFox / Safari确定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!