Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
bcaudill302
Level 7

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"?
0 Kudos
2 Replies
boomAlex
Level 7

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.

if video["container"] = invalid or video["container"]["title"] = invalid
video_title = "No Title Available"
else
video_title = video["container"]["title"]
end if
0 Kudos
bcaudill302
Level 7

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
0 Kudos