Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Preserve the order in JSON

by Anonymous Monk
on Oct 21, 2020 at 03:48 UTC ( [id://11123027]=note: print w/replies, xml ) Need Help??


in reply to Re: Preserve the order in JSON
in thread Preserve the order in JSON

I have a reason why. I have a vim command that I use that Tidies different files. :Tidy When it's perl code, it uses the Perl::Tidy. If it's JSON, then it formats it nicely using JSON::PP. Recently I've been doing comparisons of serialized JSON data (to make sure it's formatted correctly) and it would be nice if the order was maintained when being Tidied. Performance isn't critical, it's an editor command; not used in production.

Replies are listed 'Best First'.
Re^3: Preserve the order in JSON
by Anonymous Monk on Oct 21, 2020 at 03:50 UTC
    I've been using a one-liner. json_pp -f json -t json -json_opt pretty. I may end up implementing it using Hash::Ordered
Re^3: Preserve the order in JSON
by Anonymous Monk on Oct 21, 2020 at 08:44 UTC
    Use the ordering/sorting feature then nobody is stopping you

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11123027]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-26 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found