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)
import json
with open('path_to_file/person.json') as f:
data = json.load(f)
import json
uglyjson = '{"firstnam":"James","surname":"Bond","mobile":["007-700-007","001-007-007-0007"]}'
#json.load method converts JSON string to Python Object
parsed = json.loads(uglyjson)
print(json.dumps(parsed, indent=2, sort_keys=True))
import json
appDict = {
'name': 'messenger',
'playstore': True,
'company': 'Facebook',
'price': 100
}
app_json = json.dumps(appDict)
print(app_json)
import json
with open('data.txt') as json_file:
data = json.load(json_file)
# Python program to read
# json file
import json
# Opening JSON file
f = open('data.json')
# returns JSON object as
# a dictionary
data = json.load(f)
# Iterating through the json
# list
for i in data['emp_details']:
print(i)
# Closing file
f.close()