gistlib
main.pyimport json # sample JSON data json_data = '{"name": "John", "age": 30, "city": "New York"}' # parsing JSON parsed_json = json.loads(json_data) # accessing the values name = parsed_json['name'] age = parsed_json['age'] city = parsed_json['city'] # printing the values print('Name:', name) print('Age:', age) print('City:', city) 333 chars18 lines
import json # sample JSON data json_data = '{"name": "John", "age": 30, "city": "New York"}' # parsing JSON parsed_json = json.loads(json_data) # accessing the values name = parsed_json['name'] age = parsed_json['age'] city = parsed_json['city'] # printing the values print('Name:', name) print('Age:', age) print('City:', city)
Output will be:
main.pyName: John Age: 30 City: New York 34 chars4 lines
Name: John Age: 30 City: New York
gistlibby LogSnag