【发布时间】:2017-06-07 05:45:08
【问题描述】:
很明显,我不能依赖 JSON 中键值对的顺序。例如,JSON 解析器可以解释
{
"someKey" : "someValue",
"anotherKey" : "anotherValue",
"evenAnotherKey" : "evenAnotherValue"
}
作为
{
"anotherKey" : "anotherValue",
"someKey" : "someValue",
"evenAnotherKey" : "evenAnotherValue"
}
合法,但我可以依赖 JSON 数组 的顺序吗?例如,JSON 解析器能否解释
{
"arrayKey" : ["firstElement", "secondElement", "thirdElement"]
}
作为
{
"arrayKey" : ["secondElement", "firstElement1", "thirdElement"]
}
合法吗?我想不会,但我的朋友告诉我我错了。
【问题讨论】:
-
您询问的是 JSON 数组,但谈论的是 JavaScript 编译器。你在处理 JSON 还是 JavaScript?
-
@Quentin 我的意思是解析器。我将编辑问题。
标签: javascript json