Map JSON Response From Ruby To Python
[EDIT]: Sorry I didn't explain in enough details the first time as I kind of wanted to figure the rest out for myself, but I ended up confusing myself even more I have a small prob
Solution 1:
The Pythonic way is to use a list comprehension.
Word = "\n".join(subtitle["Content"] for subtitle in json["Subtitles"])
Solution 2:
You might need to convert the incoming json to python dictionary
Assuming this is your response
response = {"Subtitles": ...}
#convert to dict
import json
json_data = json.loads(response)
# print content
for a_subtitle in response['Subtitles']:
print(a_subtitle['content'])
# extract family and timestamp
family = json_data["Class"]["family"]
timestamp = json_data["Class"]["Timestamp"]
image_url = "https://example.com/image/" + family + "/" + str(timestamp)
Post a Comment for "Map JSON Response From Ruby To Python"