import json
def parseJSON(jsonDict,key):
keyList=list()
for k in jsonDict:
v = jsonDict[k]
if isinstance(v,dict):
keyList.extend(parseJSON(v,k))
elif isinstance(v,list):
if key == '':
keyList.extend(parseJsonList(v, k))
else:
keyList.extend(parseJsonList(v, key + '|' + k))
else:
if key == '':
keyList.append(k)
else:
keyList.append(key+'|'+k)
return keyList
def parseJsonList(jsonList,key):
jList = list()
for k in jsonList:
if isinstance(k,dict):
jList.extend(parseJSON(k,key))
elif isinstance(k,list):
jList.extend(parseJsonList(k,key))
return jList
tt = '{...}'
ojt = json.loads(tt)
print ('').join(parseJSON(ojt,''))
转载于:https://www.cnblogs.com/QAZLIU/p/5748159.html