Edge case with the order of results.
When the result keys are numeric (eg, ID's or just reordered list) when the JSON parser will reorder the list ASC.
This creates the impression in the Previewer that the order is incorrect while in fact it's fine in PHP and the raw response.
Few ideas:
- Custom JSON parser, or a custom JSON reviver (second param for JSON.parse() )
- Look into a React component to improve the JSON view and just send it encoded as a JSON string instead of a JSON response.
- Don't use JSON?? No idea what would be better...
Examples
<?php
[
"1" => 'one',
"3" => 'three',
"2" => 'two',
]
Becomes:
# JSON
{
"1": "one",
"2": "two",
"3": "three"
}
Edge case with the order of results.
When the result keys are numeric (eg, ID's or just reordered list) when the JSON parser will reorder the list ASC.
This creates the impression in the Previewer that the order is incorrect while in fact it's fine in PHP and the raw response.
Few ideas:
Examples
Becomes: