-
Notifications
You must be signed in to change notification settings - Fork 1
/
reviews.py
32 lines (20 loc) · 848 Bytes
/
reviews.py
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
import json
def generate_review_text_json(decoded_json):
result = []
for i in range(len(decoded_json["review"])):
result.append(decoded_json["review"][i]["description"])
return json.dumps(result)
"""
class Reviews:
def __init__(self, decoded_json: dict):
self._review_text_json = self._generate_review_text_json(decoded_json)
def get_review_text_json(self) -> json:
'''Gets the json of the reviews'''
return self._review_text_json
def _generate_review_text_json(self, decoded_json: dict):
'''Extracts the text of the reviews from the JSON data'''
result = {"reviews": []}
for i in range(len(decoded_json["review"])):
result["reviews"].append(decoded_json["review"][i]["description"])
return json.dump(result, "reviews.json")
"""