import json x = { "name": "John", "age": 30, "married": True, "divorced": False, "children": ("Ann","Billy"), "pets": None, "cars": [ {"model": "BMW 230", "mpg": 27.5}, {"model": "Ford Edge", "mpg": 24.1} ] } print(json.dumps(x))
import json # some JSON: x = '{ "name":"John", "age":30, "city":"New York"}' # parse x: y = json.loads(x) # the result is a Python dictionary: print(y["age"])
json.dumps(x, indent=4, sort_keys=True)
{ "Icons":{ "app icon": "your icon.ico", "eg icon": "eg.ico" } }
import json json_file = json.load(open("your file.json", "r", encoding="utf-8")) # For see if you don't have error: print(json_file)
json.dumps(x, indent=4, separators=(". ", " = "))
json.dumps(x, indent=4)