让我们考虑有两个json对象ONE和两个
一个
{
"logList": [
{
"logFileName": "A",
"creationTime": 1533732744000
},
{
"logFileName": "B",
"creationTime": 1534160068000
},
{
"logFileName": "C",
"creationTime": 1533278244000
},
{
"logFileName": "D",
"creationTime": 1533730389000
},
{
"logFileName": "E",
"creationTime": 1533830470000
}
]
}
两个
{
"logList": [
{
"logFileName": "A",
"creationTime": 1533732744000
},
{
"logFileName": "B",
"creationTime": 1534160068000
}
]
}
我需要弄清这两个JSON对象的区别,即
{
"logList": [
{
"logFileName": "C",
"creationTime": 1533278244000
},
{
"logFileName": "D",
"creationTime": 1533730389000
},
{
"logFileName": "E",
"creationTime": 1533830470000
}
]
}
我需要以最小的复杂度执行此操作,因为json对象的大小很大并且logFileName没有排序。
答案 0 :(得分:0)
difflist = [v for i,v in enumerate(a['logList']) if i >= len(b['logList']) or v != b['logList'][i]]
这应该有效