When working on my web application, I retrieve a JSON string from the server and store it in a variable called greetings:
var greetings = '{"2":"hoi","3":"hi","1":"salam"}'
I have observed that the greetings begin with index 2 and value hoi. After attempting to parse the JSON, I noticed the following result:
JSON.parse(greetings) // {1: "salam", 2: "hoi", 3: "hi"}
The order of the elements has changed. It appears that JSON.parse organizes the output based on the keys.
Is there a method to maintain the original ordering of the string?