如何让 jq 漂亮地打印 json 按字母顺序排列键
How can I get jq to pretty print json ordering keys alphabetically
我使用 jq 打印非常复杂 json。然后使用 diff 来比较不同的版本。有没有办法让 jq 按键按字母顺序对输出进行排序?
更快 xml 对象映射器支持这个
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);
亲切的问候
安迪
使用 -S
标志来格式化输出:
--sort-keys / -S:
Output the fields of each object with the keys in sorted order.
我使用 jq 打印非常复杂 json。然后使用 diff 来比较不同的版本。有没有办法让 jq 按键按字母顺序对输出进行排序?
更快 xml 对象映射器支持这个
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);
亲切的问候
安迪
使用 -S
标志来格式化输出:
--sort-keys / -S:
Output the fields of each object with the keys in sorted order.