I have a bunch of automatically generated JSON files that I want to store in version control. The problem is that each time the files are serialized, the attributes come out in a different order, making it hard to know if the files have really changed and / or what the real differences are.

有没有人知道现有的开放源码工具可以执行这项任务?

如果做不到这一点,有没有人知道带有解析器和生成器的JSON库可以配置为以(比方说)词汇顺序输出具有属性的"漂亮的"JSON?(Java或Ruby库将是理想的,但也欢迎其他线索.)

推荐答案

Python's JSON module is very usable from other programs:

generate_json | python -mjson.tool > canonical.json

Json相关问答推荐

两种情况下过滤的JOLT规范

JOLT转换过滤出特定值/对象

Azure Data Factory JSON输出格式问题

对一些JSON模式验证的混淆

在 VS Code 中将一个正则表达式替换为另一个正则表达式

Python 将 struct 化文本转换和筛选为对象

将 GEOSwift.JSON 转换为 Swift 中的 struct

使用 jq 从字符串列表开始创建对象

Golang gin接收json数据和图片

如何将该 JSON 解析为 Kotlin 类?

如何在 Postman 中匹配 json 响应中的内容?并可视化

在Flutter 中将 map 的 Json 转换为 list

JSON 字段的多个名称

jq:来自嵌套 JSON 的映射

如何使用 gson 调用默认反序列化

如何在 Eclipse 中安装和使用 JSON 编辑器?

谷歌浏览器不允许我放置断点

如何使用 Jackson 定义可选的 json 字段

如何使用 Javascript 将数据写入 JSON 文件

如何从 MVC 控制器返回 Json 对象以查看