Newer
Older
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
49
50
51
52
53
def parse_book_dict_to_json(dictionary):
item_list = list(dictionary.items())
return_list = []
for items in item_list:
book_package = items[1]
book_json = parse_book_to_json(book_package)
return_list.append(book_json)
return return_list
def parse_author_dict_to_json(dictionary):
item_list = list(dictionary.items())
return_list = []
for items in item_list:
author_package = items[1]
author_json = parse_author_to_json(author_package)
return_list.append(author_json)
return return_list
def parse_book_to_json(bookPKT):
book_json = {
"type": "book",
"book_url": bookPKT.url,
"title": bookPKT.title,
"id": bookPKT.id,
"ISBN": bookPKT.ISBN13,
"author_url": bookPKT.author_url,
"author": bookPKT.author,
"rating": bookPKT.rating,
"rating_count": bookPKT.rating_count,
"review_count": bookPKT.review_count,
"image_url": bookPKT.image_url,
"similar_books": bookPKT.similar_books
}
return book_json
def parse_author_to_json(authorPKT):
author_json = {
"type": "author",
"name": authorPKT.name,
"author_url": authorPKT.url,
"id": authorPKT.id,
"rating": authorPKT.rating,
"rating_count": authorPKT.rating_count,
"review_count": authorPKT.review_count,
"image_url": authorPKT.image_url,
"related_authors": authorPKT.related_authors,
"author_books": authorPKT.author_books
}
return author_json