1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    2
    Vote Rating
    0
    WTRambo is on a distinguished road

      0  

    Question Answered: Newbie working with JSON reader and nested JSON

    Answered: Newbie working with JSON reader and nested JSON


    I am trying to make a store that reads "cart-items" out of the following JSON:

    Code:
    {
        "request-status": "success",
        "session-token": "8259984ckur9678d82grfiujn7",
        "response-data": {
            "cart": {
                "cart-items": [
                    { ... },
                    { ... }
    ...
    The store I have looks like this:

    Code:
    var theStore = Ext.create('Ext.data.Store', {
                model:'CartItems',
                autoLoad: true,
                proxy: {
                    type: 'ajax',
                    url: 'data/cart.json',
                    reader: {
                        type: 'json',
                        root: 'response-data',
                        record: 'cart-items'
                    }
                },
    Now I am pretty sure I am getting no data back because there is the 'cart' level JSON between the 'response-data' and the 'cart-items'. I can't rearrange the JSON easily, is there a way to do this or do I need to look into a custom reader for this?

    Thanks,
    Rambo.

  2. I believe that you can use a function for root as well:
    Code:
    root:function(item){return item['response-data']['cart'] };
    Haven't tested it, but I remember using something like this in one of my Sencha Touch 1 apps.

  3. #2
    Sencha User
    Join Date
    Sep 2011
    Posts
    46
    Answers
    1
    Vote Rating
    0
    Zyphrax is on a distinguished road

      0  

    Default


    I believe that you can use a function for root as well:
    Code:
    root:function(item){return item['response-data']['cart'] };
    Haven't tested it, but I remember using something like this in one of my Sencha Touch 1 apps.

  4. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    2
    Vote Rating
    0
    WTRambo is on a distinguished road

      0  

    Default


    That worked, thanks!

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar