Python Lire le fichier JSON
import json
with open('path_to_file/person.json') as f:
data = json.load(f)
print(data)
MzanziLegend
import json
with open('path_to_file/person.json') as f:
data = json.load(f)
print(data)
data = {
"your json": "has data!"
}
with open('data.txt', 'w') as outfile:
json.dump(data, outfile)
import json
with open('data.json', 'w') as f:
json.dump(data, f)
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"])