is there a way to preserve the order
Not exactly, but JSON can sort JSON object keys. You need to call $json->canonical() before $json->encode($data). Note that this adds some significant overhead.
The big question remains: Why do you need sorted keys in the object?
Alexander
In reply to Re: Preserve the order in JSON
by afoken
in thread Preserve the order in JSON
by user786
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |