2017-05-10, 19:07
(2017-05-10, 12:45)axlt2002 Wrote:(2017-05-09, 20:16)ralfonat Wrote:(2017-05-09, 16:37)axlt2002 Wrote: Basically, which is the code/syntax to save in a local variable (e.g. IMDb_id) the received tt4574334 value? I have tried the following code but the result in IMDb_id is None:jSonResponse.result.tvshows["0"].uniqueid.imdb
Code:for item in jSonResponse['result']['tvshows']:
IMDb_id = item.get('uniqueid[0]')
Thanks for any help...and sorry for the stupid question, but I'm just facing JSON and python for the first time!
or
jSonResponse.["result"]["tvshows"][0]["uniqueid"]["imdb"]
Thanks for your answer ralfonat.
I have tried both solutions you proposed but the first one doesn't provide any result while the second one gives a syntax error...I'm puzzled...and stuck!
Sorry, I hit reply earlier before noticing there was a list inside the dict.
ralfonat was close, try the following instead.
Code:
jSonResponse["result"]["tvshows"][0]["uniqueid"]["imdb"]
If you're looking to loop through it in the case that the json returns multiple shows, you can use the following code to do that.
Code:
for item in jSonResponse['result']['tvshows']:
imdb_id = item['uniqueid']['imdb']