bcaudill302
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2016
08:58 AM
Json error handling if object does not exist
for each video in json["schedule"][0]["items"]
video_title = video["container"]["title"]
Sometimes ["container"]["title"] does not exit in some of the returned json files, how would I go about skipping the error and just saying that video_title = "No Title Available"?
2 REPLIES 2
boomAlex
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2016
12:38 PM
Re: Json error handling if object does not exist
Just do a quick check to see if video["container"]["title"] is invalid.
Something like this I would think.
Something like this I would think.
if video["container"] = invalid or video["container"]["title"] = invalid
video_title = "No Title Available"
else
video_title = video["container"]["title"]
end if
bcaudill302
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2016
02:17 PM
Re: Json error handling if object does not exist
Works perfect, but I swear I tried this several times before and kept getting errors lol. I could just be going crazy. Thanks for the help