Keep order of objects inside a JSON String after they are parsed

后端 未结 6 1280
礼貌的吻别
礼貌的吻别 2021-01-18 09:42

I receive the following JSON string from an API function.

\"Inbound\": {
    \"callRelatedFields\": [\"ANI\",
    \"DNIS\"],
    \"objects\": {
        \"Con         


        
6条回答
  •  星月不相逢
    2021-01-18 09:47

    Unfortunately object properties are unordered in JavaScript so you shouldn't rely on being able to iterate over them in a particular sequence.

    I would suggest accessing the properties by name in the order you need them, rather than just iterating over the list.

提交回复
热议问题