1.已知节点路径
def selectJsonBykeyChain(keyChain, json):
# keyChain 'a.b.c'
keyList = str.split(keyChain, '.')
val = json;
for k in keyList:
# print(k)
val = val[k]
return val
2.已知节点key值
def selectJsonByKey(key, jsonb):
for k in jsonb:
if k==key:
return jsonb[k]
chlidType = type(jsonb[k])
if dict == chlidType:
print('进入到了子节点'+k)
return selectJsonByKey(key,jsonb[k])
网友评论