python read json file
import json
with open('path_to_file/person.json') as f:
data = json.load(f)
print(data)
python read json file
import json
with open('path_to_file/person.json') as f:
data = json.load(f)
print(data)
how to get specific data from json using python
with open('distros.json', 'r') as f:
distros_dict = json.load(f)
for distro in distros_dict:
print(distro['Name'])
convert class object to json python
import json
class Laptop:
name = 'My Laptop'
processor = 'Intel Core'
#create object
laptop1 = Laptop()
laptop1.name = 'Dell Alienware'
laptop1.processor = 'Intel Core i7'
#convert to JSON string
jsonStr = json.dumps(laptop1.__dict__)
#print json string
print(jsonStr)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us