1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    21
    Vote Rating
    1
    Answers
    1
    Souri is on a distinguished road

      0  

    Default Answered: Ext.data.Model mapping unkown fields

    Answered: Ext.data.Model mapping unkown fields


    Hi, I'm trying to figure out how to map JSON data from my mediawiki site... an example of the json structure is:

    Code:
    {
      "query": {
        "normalized": [
          {
            "from": "From",
            "to": "To"
          }
        ],
        "pages": {
          "566": {
            "pageid": 566,
            "ns": 0,
            "title": "title here",
            "revisions": [
              {
                "booyah"
              }
            ]
          }
        }
      }
    }
    I want to get the details in "revisions" but the problem is that it's parent field ('566' in this case) is different for every page. How do I correctly map to get the revisions data if that field is always different?

  2. Once you have a valid JSON-format (always "key": "value", so "booyah" over there is invalid),
    you can decode the JSON-string with Ext.JSON.decode(string).
    Then i think you can get your wanted values with the array-notation.
    Something like decodedJson.pages[0].revisions

  3. #2
    Sencha User
    Join Date
    Aug 2011
    Location
    Belgium
    Posts
    29
    Vote Rating
    4
    Answers
    4
    gamevampy is on a distinguished road

      0  

    Default


    Once you have a valid JSON-format (always "key": "value", so "booyah" over there is invalid),
    you can decode the JSON-string with Ext.JSON.decode(string).
    Then i think you can get your wanted values with the array-notation.
    Something like decodedJson.pages[0].revisions

  4. #3
    Sencha User
    Join Date
    Jan 2012
    Posts
    21
    Vote Rating
    1
    Answers
    1
    Souri is on a distinguished road

      0  

    Default


    Thanks for your reply. I got my json in the reader where it's an object and converted to a string with Ext.JSON.encode(object).

    Anyway, with a bunch of string manipulations on that, I finally got the data I was after!

Thread Participants: 1