是否有任何命令行实用程序可用于查找两个JSON文件是否相同,但字典内键和列表内元素顺序不变?
可以使用jq
其他等效工具完成此操作吗?
例子:
这两个JSON文件是相同的
A
:
{
"People": ["John", "Bryan"],
"City": "Boston",
"State": "MA"
}
B
:
{
"People": ["Bryan", "John"],
"State": "MA",
"City": "Boston"
}
但是这两个JSON文件不同:
A
:
{
"People": ["John", "Bryan", "Carla"],
"City": "Boston",
"State": "MA"
}
C
:
{
"People": ["Bryan", "John"],
"State": "MA",
"City": "Boston"
}
那将是:
$ some_diff_command A.json B.json
$ some_diff_command A.json C.json
The files are not structurally identical
--argfile a a.json
的--arg a $a
(即$ AA JSON字符串),没有运气。任何想法如何处理字符串,而不是文件?