0
Q:

json.load

import json

with open('data.txt') as json_file:
    data = json.load(json_file)
0

import json

with open('path_to_file/person.json') as f:
  data = json.load(f)
1
# 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() 
2
# a Python object (dict):
x = {
  "name": "John",
  "age": 30,
  "city": "New York"
}

# convert into JSON:
y = json.dumps(x)
2

    json.dumps(x, indent=4, sort_keys=True)
 
2

import json

with open('path_to_file/person.json') as f:
  data = json.load(f)

# Output: {'name': 'Bob', 'languages': ['English', 'Fench']}
print(data)
0

New to Communities?

Join the community