Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
bcaudill302
Visitor

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 2
boomAlex
Visitor

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
Visitor

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