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: 
btpoole
Level 7

Getting Value From json

Working with the following json data.


{
"current_observation": {
"image": {
"url":"http://icons.wxug.com/graphics/wu2/logo_130x80.png",
"title":"Weather Underground",
"link":"http://www.wunderground.com"
},
"display_location": {
"full":"MyCity, MyState",
"city":"MyCity",
"state":"MyState",
"state_name":MyState",
"country":"MyCountry",
"country_iso3166":"MyCountry",
"zip":"MyZipCode",
},
}


Attempting to get the value from the "full". With the following the only thing I get back are the element names but not the value.

full
city
state
state_name
country
country_iso3166
zip


for each display_location in result.current_observation.display_location
?display_location
end for

Have tried ?display_location.full but get syntax error. From what I see in the sdk example this should work. Can somebody point out the simple mistake I am making? Thanks
0 Kudos
3 Replies
hugetv
Level 7

Re: Getting Value From json

"btpoole" wrote:
Working with the following json data.


{
"current_observation": {
"image": {
"url":"http://icons.wxug.com/graphics/wu2/logo_130x80.png",
"title":"Weather Underground",
"link":"http://www.wunderground.com"
},
"display_location": {
"full":"MyCity, MyState",
"city":"MyCity",
"state":"MyState",
"state_name":MyState",
"country":"MyCountry",
"country_iso3166":"MyCountry",
"zip":"MyZipCode",
},
}


Attempting to get the value from the "full". With the following the only thing I get back are the element names but not the value.

full
city
state
state_name
country
country_iso3166
zip


for each display_location in result.current_observation.display_location
?display_location
end for

Have tried ?display_location.full but get syntax error. From what I see in the sdk example this should work. Can somebody point out the simple mistake I am making? Thanks


so I would use

videos = CreateObject("roArray", 100, true)
for each item in json.current_observation
this = {
title: item.title
city: item.city
state: item.state
}
videos.Push(this)
next
return videos
Our system http://www.rokumanager.com
0 Kudos
belltown
Level 7

Re: Getting Value From json

You should just be able to do:


?result.current_observation.display_location.full
https://github.com/belltown/
0 Kudos
btpoole
Level 7

Re: Getting Value From json

Thanks
?result.current_observation.display_location.full
worked.
0 Kudos