Joined April 2017
·

lastorset

Expectation Management as a Service at auka.io
·
Oslo, Norway
·
·
·

Posted to Format JSON in vim over 1 year ago

jlb333333:

Unfortunately it sorts the json alphabetically. is there a switch to prevent this sorting. I want to keep my document in it's original order.
Otherwise an absolutely amazing tool.

Try

:%!python -c "import json, sys, collections; print json.dumps(json.load(sys.stdin, object_pairs_hook=collections.OrderedDict), indent=4)"

Unfortunately, this adds a space at the end of every line. But that's simple enough to delete afterwards.

Achievements
1 Karma
0 Total ProTip Views
Interests & Skills