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

后端 未结 6 1282
礼貌的吻别
礼貌的吻别 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:51

    As per the JSON standard, an object is unordered. So if you care about the order "Contact", "Account", "cnx__Phone__c", put them in an array ([]).

    Maybe it's enough to put the property names themselves in an array next to the .objects themselves, so that you still can access them by their names. Many structures are valid solutions.

提交回复
热议问题