I am trying to return a specific field from a json result. Here is what I am trying to do with it:
rjson = json.loads("{u'tv_season_results': [], u'tv_episode_results': [], u'person_results': [], u'tv_results': [], u'movie_results': [{u'poster_path': u'/5SjtNPD1bb182vzQccvEUpXHFjN.jpg', u'title': u'(500) Days of Summer', u'overview': u'Tom (Joseph Gordon-Levitt), greeting-card writer and hopeless romantic, is caught completely off-guard when his girlfriend, Summer (Zooey Deschanel), suddenly dumps him. He reflects on their 500 days together to try to figure out where their love affair went sour, and in doing so, Tom rediscovers his true passions in life.', u'release_date': u'2009-07-17', u'popularity': 3.598717, u'original_title': u'(500) Days of Summer', u'backdrop_path': u'/yYw9cVdRJ4zzwxM2cTDXfT6JI6E.jpg', u'vote_count': 1239, u'video': False, u'adult': False, u'vote_average': 7.3, u'genre_ids': [35, 18, 10749], u'id': 19913, u'original_language': u'en'}]}")
however, I get the following error when running it:
ValueError: Expecting property name: line 1 column 2 (char 1)
EDIT:
Here is the full program (minus the API key):
import requests, json
r = requests.get('https://api.themoviedb.org/3/find/'+'tt1022603'+'?api_key=###&external_source=imdb_id')
print str(r.json())
rjson = json.loads("{u'tv_season_results': [], u'tv_episode_results': [], u'person_results': [], u'tv_results': [], u'movie_results': [{u'poster_path': u'/5SjtNPD1bb182vzQccvEUpXHFjN.jpg', u'title': u'(500) Days of Summer', u'overview': u'Tom (Joseph Gordon-Levitt), greeting-card writer and hopeless romantic, is caught completely off-guard when his girlfriend, Summer (Zooey Deschanel), suddenly dumps him. He reflects on their 500 days together to try to figure out where their love affair went sour, and in doing so, Tom rediscovers his true passions in life.', u'release_date': u'2009-07-17', u'popularity': 3.598717, u'original_title': u'(500) Days of Summer', u'backdrop_path': u'/yYw9cVdRJ4zzwxM2cTDXfT6JI6E.jpg', u'vote_count': 1239, u'video': False, u'adult': False, u'vote_average': 7.3, u'genre_ids': [35, 18, 10749], u'id': 19913, u'original_language': u'en'}]}")
where I do the loads() I just put the print from the line above.
repr()output for a dictionary.r.json()already returns a parsed Python dict. There is no need to calljson.loads()on it again.