Results 1 to 3 of 3

Thread: Modeling semi-complicated json structures

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    16
    Vote Rating
    0
      0  

    Default Answered: Modeling semi-complicated json structures

    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:

    Code:
    {
        "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"
        }]
    }

  2. 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.

  3. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,026
    Answers
    3976
    Vote Rating
    1367
      0  

    Default

    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.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    16
    Vote Rating
    0
      0  

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •