31 Years of Python | 48 Hour Sale Extension!!!

.json() return pyhton object? how to read the output?

Screen Link: https://app.dataquest.io/m/52/working-with-apis/8/getting-json-from-a-request

The return of .json()is dictionary. but it seems more complicated than the dictionary we saw before. when we try:

  • Get the duration value of the ISS’ first pass over San Francisco and assign the value to first_pass_duration .

below code means that we take the value from first-row ,duration column of response dataset,correct?

My Code:

first_pass_duration = json_data["response"][0]["duration"]

Below is the return, message, request, all of these are column names? how to read below output?
{‘message’: ‘success’, ‘request’: {‘latitude’: 37.78, ‘datetime’: 1441417753, ‘longitude’: -122.41, ‘altitude’: 100, ‘passes’: 5}, ‘response’: [{‘risetime’: 1441456672, ‘duration’: 369}, {‘risetime’: 1441462284, ‘duration’: 626}, {‘risetime’: 1441468104, ‘duration’: 581}, {‘risetime’: 1441474000, ‘duration’: 482}, {‘risetime’: 1441479853, ‘duration’: 509}]}

1 Like

Hi @candiceliu93
I asked the same thing once and @info.victoromondi gave an amazing answer here

1 Like

Thank you!!!
it helps

1 Like