I have this:
String foo =
"options": {
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
}
But the JSONObject constructor rearranges the keys:
new JSONObject(foo).toString() =
"options": {
"6",
"3",
"7",
"2",
"5",
"1",
"4",
"8",
"9",
}
The new order is reproducible, meaning each execution results in the same (seemingly random) rearrangement.
That does not look like valid JSON to me. First, there is not
{}or[]surrounding the entire string. Second, it looks like the data associated withoptionsshould be inside and array ([]) not be an object({}). If it was an array, the order would be preserved, whereas with the values just being declared as properties, there is no guarantee on their order.