Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json,sys, linecache
- from pprint import pprint
- def jsonExtract(file):
- with open(file) as data_file:
- data = json.load(data_file)
- for i in data['projects']:
- keyList = i.keys()
- pprint(keyList)
- #print keyList['category']
- for j in i.keys():
- if isinstance(i[str(j)],dict):
- print str(i[str(j)].keys())
- if __name__ == '__main__':
- try:
- print "pre exec"
- jsonExtract('webContent.json')
- print "executed"
- except TypeError as e:
- printException()
- print "Something went wrong:...",e,"...on line",str(sys.exc_info()[2].tb_lineno)
- def printException():
- exc_type, exc_obj, tb = sys.exc_info()
- f = tb.tb_frame
- lineno = tb.tb_lineno
- filename = str(f.f_code)
- linecache.checkcache(filename)
- line = linecache.getline(filename, lineno, f.f_globals)
- print 'EXCEPTION IN ({}, LINE {} "{}"): {}'.format(filename, lineno, line.strip(), exc_obj)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement