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)
with open('output.json', 'w') as outfile:
json.dump(data, outfile)
import json
data = {"key": "value"}
with open('data.json', 'w') as jsonfile:
json.dump(data, jsonfile)
import json
with open('data.json', 'w') as f:
json.dump(data, f)
# to write on file
# data_dict is a dictionary
import json
with open('data.json', 'w') as f:
json.dump(data_dict, f)
import json
with open('data.txt') as json_file:
data = json.load(json_file)
for p in data['people']:
print('Name: ' + p['name'])
print('Website: ' + p['website'])
print('From: ' + p['from'])
print('')