Contentful logo

Contentful Community

How to prevent automatic sort of a json object?

I am trying to build a table from a JSON object.
I added a JSON object through JSON editor and published it.
But it was automatically sorted, the sort should be avoided.

For example: I have a JSON object like the following.
{
“Serving Size”: “20z”,
“servingTable”: [“Table 1”],
“Serving Per Container”: “About 28”,
": “Test”
}
After saving it, the JSON object was automatically updated like this.
{
"
”: “Test”,
“Serving Size”: “20z”,
“servingTable”: [
“Table 1”
],
“Serving Per Container”: “About 28”
}
Can I save a JSON object without automatic sort?

Hi @gavl.yin.dev, this is how JSON behaves. See the stack overflow question here: java - JSONObject : Why JSONObject changing the order of attributes - Stack Overflow

To resolve the issue you’d need to come up with a custom app that replaces the default JSON object field.