使用python2.7,我想删除JSON中名为errCode和errMsg的所有键
我的JSON示例:
json_string = '''\
{
"vacation":
[
{
"dates": [
{
"duration": 360,
"dateTo": "4.2.2014",
"dateFrom": "2.1.2014"
}
],
"worker": "8"
},
{
"dates": [
{
"duration": 420,
"dateTo": "",
"dateFrom": "29.01.2015",
"errCode": "1",
"errMsg": "Missing dateTo"
}
],
"worker": "2"
}
],
"general": {
"scriptComment": "",
"scriptTo": "",
"errCode": "2",
"errMsg": "Missing comment.",
"scriptFrom": "01.01.2014"
}
}
'''
我不需要删除所有的错误代码
将JSON解码为python字典,然后递归地删除键:
演示:
^{pr2}$相关问题 更多 >
编程相关推荐