Skip to content

Instantly share code, notes, and snippets.

@nkmrtkhd
Created February 4, 2019 07:43
Show Gist options
  • Save nkmrtkhd/7df51fa48dd94ce4a1ae5e7df53e62f0 to your computer and use it in GitHub Desktop.
Save nkmrtkhd/7df51fa48dd94ce4a1ae5e7df53e62f0 to your computer and use it in GitHub Desktop.
import glob
import json
def listArray(key,arr):
for a in arr:
if type(a) is list:
listArray(key,a)
elif type(a) is dict:
listDic(key,a)
else:
print(key,a)
def listDic(key,dic):
for k,v in dic.items():
if type(v) is list:
listArray(key+"\t"+k,v)
elif type(v) is dict:
listDic(key+"\t"+k,v)
else:
print(key+"\t"+k,v)
for fpath in glob.glob("./*.json"):
print(fpath)
f=open(fpath,'r')
dic=json.load(f)
for key,val in dic.items():
if type(val) is list:
listArray(key,val)
elif type(val) is dict:
listDic(key,val)
else:
print(key,val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment