python怎么验证两个json是不是一样_比较Python中的两个JSON树
我有這種JSON樹的文件夾結(jié)構(gòu)。有什么方法可以將它與同類的Json樹進(jìn)行比較以獲得差異(文件丟失或不同的文件屬性(日期,crc,..)),并將其作為具有不同/缺失文件名稱的列表返回。比較Python中的兩個(gè)JSON樹
{
"testfolder": {
"children": {
"content.json": {
"last_modified_timestamp": 1485902084.0222416,
"created_timestamp": 1485193414.5027652,
"crc": "7c71cf7ff765ddd78fffcac2eed56ae2",
"type": "file",
"size": 961
},
"config.json": {
"last_modified_timestamp": 1484831126.4821935,
"created_timestamp": 1484830625.6165457,
"crc": "bff5d42e18df483841aa10df8b38cdd4",
"type": "file",
"size": 132
}
}
},
"__init__.py": {
"last_modified_timestamp": 1481651800.7150106,
"created_timestamp": 1481651800.7150106,
"crc": "d41d8cd98f00b204e9800998ecf8427e",
"type": "file",
"size": 0
},
"test.json": {
"last_modified_timestamp": 1486126931.2528062,
"created_timestamp": 1486126732.7074502,
"crc": "8a30d9b3834ef46ad3b996edb06c72bf",
"type": "file",
"size": 1675
},
"test": {
"children": {
"test.txt.txt": {
"last_modified_timestamp": 1486126927.9266162,
"created_timestamp": 1486126865.9750726,
"crc": "b5301fdbf2ba41520b255a651c7017b1",
"type": "file",
"size": 5
}
}
}
}
謝謝你的幫忙!
2017-02-22
Slajc
+0
那么你嘗試過這么遠(yuǎn)嗎? –
+1
加載在字典中,然后使用比較字典,就像那一個(gè)無數(shù)的答案:http://stackoverflow.com/questions/4527942/comparing-two-dictionaries-in-python –
+0
我已經(jīng)嘗試過遞歸返回列表具有完整路徑的文件而不僅僅是兩個(gè)列表之間的區(qū)別,但是這只解決了缺失文件而不是不同文件。 –
總結(jié)
以上是生活随笔為你收集整理的python怎么验证两个json是不是一样_比较Python中的两个JSON树的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 再次定义折叠屏!华为Mate X3轻薄可
- 下一篇: python处理nc文件并输出_利用py