forked from spierre91/medium_code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_tutorial.py
More file actions
48 lines (34 loc) · 1.33 KB
/
Copy pathjson_tutorial.py
File metadata and controls
48 lines (34 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'''
{
"album_title":"Yellow Submarine",
"release_year":1966 ,
"won_grammy": false,
"band": "The Beatles",
"musicians": ["John Lennon", "Paul McCartney", "George Harrison", "Ringo Starr"],
"studio": {"studio_name": "Abbey Road Studios", "location": "London, England"}
}
'''
import json
print(dir(json))
album_json_file = open("album.txt", "r")
album = json.load(album_json_file)
album_json_file.close()
print(album)
print("Object type: ", type(album))
print("Album Title: ", album['album_title'])
print("Release Year: ", album['release_year'])
album_s_json_file = """{"album_title" : "Yellow Submarine",
"release_year" : 1966,
"won_grammy" : false,
"band" : "The Beatles",
"album_sale": null,
"musicians" : ["John Lennon", "Paul McCartney", "George Harrison", "Ringo Starr"],
"studio" : {"studio_name": "Abbey Road Studios", "location": "London, England"}
}"""
album_s = json.loads(album_s_json_file)
print(album_s)
album = {'album_title': 'Yellow Submarine', 'release_year': 1966, 'won_grammy': False,
'band': 'The Beatles', 'album_sale': None, 'musicians': ['John Lennon', 'Paul McCartney', 'George Harrison', 'Ringo Starr'],
'studio': {'studio_name': 'Abbey Road Studios', 'location': 'London, England'}}
print(json.dumps(album))
print(type(json.dumps(album)))