Skip to content

Instantly share code, notes, and snippets.

@ShakoHo
Created November 29, 2016 07:56
Show Gist options
  • Save ShakoHo/6e1e03cb0222296c87dfddadc29385e2 to your computer and use it in GitHub Desktop.
Save ShakoHo/6e1e03cb0222296c87dfddadc29385e2 to your computer and use it in GitHub Desktop.
import json
import copy
with open('test.json') as fh:
o = json.load(fh)
result = copy.deepcopy(o)
for case_name in o:
for browser_type in o[case_name]:
new_origin_values = []
for values in o[case_name][browser_type]['origin_values']:
new_origin_values.append({"load": values[0], "si": values[1], "psi": values[2], "video":values[3], "ip": values[4]})
result[case_name][browser_type]['origin_values'] = copy.deepcopy(new_origin_values)
with open('output.json', 'w+') as write_fh:
json.dump(result, write_fh)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment