Forum Discussion

btpoole's avatar
btpoole
Channel Surfer
10 years ago

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
  • "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
  • You should just be able to do:


    ?result.current_observation.display_location.full
  • btpoole's avatar
    btpoole
    Channel Surfer
    Thanks
    ?result.current_observation.display_location.full
    worked.