How can I get jq to beautifully print json sort buttons in alphabetical order

I use jq to print very complex json. then use diff to compare another version. Is there a way I can get jq to sort the output alphabetically with keys?

XML accelerators have support for this.

prettyPrintObjectMapper = new ObjectMapper(); prettyPrintObjectMapper.configure(SerializationFeature.INDENT_OUTPUT, true); //turn on prettyPrintObjectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); String tmp1 = prettyPrintObjectMapper.writeValueAsString(myObject); 

Yours faithfully

Andy

+6
source share
1 answer

Use the -S flag to format the output as follows:

- sort-keys / -S:

Display the fields of each object using the keys in sorted order.

+9
source

All Articles