in reply to Preserve the order in JSON
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
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Preserve the order in JSON (overhead)
by tye (Sage) on Dec 28, 2016 at 19:34 UTC |
In Section
Seekers of Perl Wisdom