diff --git a/docs/pyerrors/input/json.html b/docs/pyerrors/input/json.html index a556548a..bb0d55bf 100644 --- a/docs/pyerrors/input/json.html +++ b/docs/pyerrors/input/json.html @@ -359,22 +359,24 @@ ret[-1].tag = taglist[i] return np.reshape(ret, layout) - prog = json_string.get('program', '') - version = json_string.get('version', '') - who = json_string.get('who', '') - date = json_string.get('date', '') - host = json_string.get('host', '') + json_dict = json.loads(json_string) + + prog = json_dict.get('program', '') + version = json_dict.get('version', '') + who = json_dict.get('who', '') + date = json_dict.get('date', '') + host = json_dict.get('host', '') if prog and verbose: print('Data has been written using %s.' % (prog)) if version and verbose: print('Format version %s' % (version)) if np.any([who, date, host] and verbose): print('Written by %s on %s on host %s' % (who, date, host)) - description = json_string.get('description', '') + description = json_dict.get('description', '') if description and verbose: print() print('Description: ', description) - obsdata = json_string['obsdata'] + obsdata = json_dict['obsdata'] ol = [] for io in obsdata: if io['type'] == 'Obs': @@ -426,12 +428,12 @@ if not fname.endswith('.gz'): fname += '.gz' with gzip.open(fname, 'r') as fin: - d = json.loads(fin.read().decode('utf-8')) + d = fin.read().decode('utf-8') else: if fname.endswith('.gz'): warnings.warn("Trying to read from %s without unzipping!" % fname, UserWarning) with open(fname, 'r', encoding='utf-8') as fin: - d = json.loads(fin.read()) + d = fin.read() return import_json_string(d, verbose, full_output) @@ -785,22 +787,24 @@ If True, the output is a gzipped json. If False, the output is a json file. ret[-1].tag = taglist[i] return np.reshape(ret, layout) - prog = json_string.get('program', '') - version = json_string.get('version', '') - who = json_string.get('who', '') - date = json_string.get('date', '') - host = json_string.get('host', '') + json_dict = json.loads(json_string) + + prog = json_dict.get('program', '') + version = json_dict.get('version', '') + who = json_dict.get('who', '') + date = json_dict.get('date', '') + host = json_dict.get('host', '') if prog and verbose: print('Data has been written using %s.' % (prog)) if version and verbose: print('Format version %s' % (version)) if np.any([who, date, host] and verbose): print('Written by %s on %s on host %s' % (who, date, host)) - description = json_string.get('description', '') + description = json_dict.get('description', '') if description and verbose: print() print('Description: ', description) - obsdata = json_string['obsdata'] + obsdata = json_dict['obsdata'] ol = [] for io in obsdata: if io['type'] == 'Obs': @@ -884,12 +888,12 @@ If False, only the data is returned. if not fname.endswith('.gz'): fname += '.gz' with gzip.open(fname, 'r') as fin: - d = json.loads(fin.read().decode('utf-8')) + d = fin.read().decode('utf-8') else: if fname.endswith('.gz'): warnings.warn("Trying to read from %s without unzipping!" % fname, UserWarning) with open(fname, 'r', encoding='utf-8') as fin: - d = json.loads(fin.read()) + d = fin.read() return import_json_string(d, verbose, full_output)