def read_json(curdir,fieldname): """read json-file and return dict""" fr = open(os.path.join(curdir,fieldname), "r") text = fr.read() fr.close #if isinstance(eval(text),list): pass if text.startswith("["): pass #we have a list else: text = '[' + text +']' jsontext = washJSONinput(text) jsondict_list = json.loads(jsontext, 'utf8') return jsondict_list
def get_pubtype_info(doctype): """call output format for publication types and return it as dictionary (json)""" # directly call the backend... query = '3367_:'+doctype res = perform_request_search(p=query, cc='PubTypes') # and return the first rec in JS for further processing if res == []: return {} text = print_record(res[0], 'js') jsontext = washJSONinput(text) jsondict = json.loads(jsontext, 'utf8') return jsondict