pretty dump
import json
json_data = '[{"ID":10,"Name":"Pankaj","Role":"CEO"},' \
'{"ID":20,"Name":"David Lee","Role":"Editor"}]'
json_object = json.loads(json_data)
json_formatted_str = json.dumps(json_object, indent=2)
print(json_formatted_str)
3
1
echo '<pre>' . var_export($data, true) . '</pre>';
Thank you!
1
0
5
1
highlight_string("<?php\n\$data =\n" . var_export($data, true) . ";\n?>");
Thank you!
1
0
4.11
9
import json
# alphabetic dictionary
json_data = {hex(k): chr(k) for k in range(ord('a'), ord('z') + 1)}
# to file
with open("my_json.json", "w") as file:
json.dump(json_data, file, indent=4, sort_keys=True)
Thank you!
9
0
Are there any code examples left?
New code examples in category PHP