Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- x= {
- "BTC" : {
- "price": 5000
- },
- "ETH" : {
- "price": 1000
- }
- }
- # convert into JSON:
- y = json.dumps(x)
- # create a simple JSON array
- # change the JSON string into a JSON object
- json_object = json.loads(y)
- # print the keys and values
- for key in json_object:
- value = json_object[key]
- print("The key and value are ({}) = ({})".format(key, value))
- btc_obj = json_object['BTC']
- print(btc_obj["price"])
- print(type(obj))
- print(obj.items())
- #print(json_object['ETH]["price"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement