-
6 May 2012 10:45 AM #1
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:
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?Code:{ "query": { "normalized": [ { "from": "From", "to": "To" } ], "pages": { "566": { "pageid": 566, "ns": 0, "title": "title here", "revisions": [ { "booyah" } ] } } } }
-
Best Answer Posted by gamevampy
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
-
6 May 2012 11:48 AM #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
-
25 May 2012 9:31 AM #3
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!


Reply With Quote