Is the order of elements in a JSON list preserved?

后端 未结 5 903
半阙折子戏
半阙折子戏 2020-11-22 12:20

I\'ve noticed the order of elements in a JSON object not being the original order.

What about the elements of JSON lists? Is their order maintained?

5条回答
  •  故里飘歌
    2020-11-22 12:38

    The order of elements in an array ([]) is maintained. The order of elements (name:value pairs) in an "object" ({}) is not, and it's usual for them to be "jumbled", if not by the JSON formatter/parser itself then by the language-specific objects (Dictionary, NSDictionary, Hashtable, etc) that are used as an internal representation.

提交回复
热议问题