PDA

View Full Version : Modeling semi-complicated json structures



Thomas The Fourth
5 Mar 2012, 7:57 AM
Hello,

I'm trying to read a json feed from yahoo weather. Seems like a pretty simple response, but I can't figure out the approach I should use to bring the data into my model. I was thinking jsonReader might be key, but it doesn't seem to support the format. Any help would be appreciated. Thanks. Here the response:



{
"units": {
"temperature": "F",
"speed": "mph",
"distance": "mi",
"pressure": "in"
},
"location": {
"location_id": "USLA0338",
"city": "New Orleans",
"state_abbreviation": "LA",
"country_abbreviation": "US",
"elevation": 13,
"latitude": 29.97000000000000,
"longitude": -90.09000000000000
},
"wind": {
"speed": 10.00000000000000,
"direction": "WNW"
},
"atmosphere": {
"humidity": "67",
"visibility": "10",
"pressure": "30.39",
"rising": "rising"
},
"url": "http:\/\/weather.yahoo.com\/forecast\/USLA0338.html",
"logo": "http:\/\/l.yimg.com\/a\/i\/us\/nt\/ma\/ma_nws-we_1.gif",
"astronomy": {
"sunrise": "06:21",
"sunset": "18:03"
},
"condition": {
"text": "Fair",
"code": "34",
"image": "http:\/\/l.yimg.com\/a\/i\/us\/we\/52\/34.gif",
"temperature": 62.00000000000000
},
"forecast": [{
"day": "Today",
"condition": "Sunny",
"high_temperature": "72",
"low_temperature": "52"
}, {
"day": "Tomorrow",
"condition": "Mostly Sunny",
"high_temperature": "70",
"low_temperature": "62"
}]
}

mitchellsimoens
5 Mar 2012, 8:28 AM
A Store needs an array so this response wouldn't work. You could use a store and get the forecasts but the other info wouldn't be part of any record.

Thomas The Fourth
5 Mar 2012, 8:49 AM
Thanks for the reply. Is there no way to massage the data prior to ingest? It seems like this would be something that would commonly need to be done.