1

I'm trying to getJSON the following json data:

{
  "count": 96,
  "value": {
    "title": "cotripWeatherStations",
    "description": "Pipes Output",
    "link": "http:\/\/pipes.yahoo.com\/pipes\/pipe.info?_id=f43ccc14ab9d1c88d537236e93c1525e",
    "pubDate": "Mon, 03 Sep 2012 02:17:48 +0000",
    "generator": "http:\/\/pipes.yahoo.com\/pipes\/",
    "callback": "",
    "items": [
      {
        "ws:Location": {
          "global:Latitude": "37.086807",
          "global:Longitude": "-104.521294"
        },
        "ws:Device": {
          "global:DeviceId": "6796",
          "global:CommonName": "025N008  RATON PASS (RWIS)",
          "global:Status": "enabled",
          "global:EntityId": "1",
          "global:RoadId": "31",
          "global:RoadName": "I-25",
          "global:Direction": "North",
          "global:MileMarker": "8",
          "global:LastUpdateDate": "2012-08-26T13:52:00.000-06:00",
          "global:Icon": "theme\/cotrip.org\/images\/devices\/icon_device_weather_station_with_cam_16x23.gif"
        }
      }
   ]
}

the following code gives me an alert with output, but no data:

var weather = $.getJSON("http://pipes.yahoo.com/pipes/pipe.run?_id=f43ccc14ab9d1c88d537236e93c1525e&_render=json&_callback=?", function(json) {
  alert("JSON Data: " + json.value["items"]);
});

how do I traverse further into this JSON to 'ws:Devise - "global:CommonName"

1 Answer 1

6

How about

json.value.items[0]['ws:Device']['global:CommonName']

?

http://jsfiddle.net/zerkms/D2JKR/

Sign up to request clarification or add additional context in comments.

1 Comment

thanks zerkms, that works great! here is my jsFiddle showing the alert jsfiddle.net/tutone/8k4AV/3 most importantly I can move forward now that I know how to work with this complex data!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.