1

My output ![my output][1]

I have been trying to parse nested json from a url but i cannot parse it fully and i have looked into available all link: link1 link2 link3 link4

This was my previous question

my json is

({
"accountInfo": {
    "expire_date": "2014-07-02 08:01:09",
    "subscribe_date": "2013-07-02 08:01:09",
    "time_remain": " 355 Days 20 Hours 47 Minutes",
    "status": "not expired"
},
"status": "TRUE",
"message": "Todays Word",
"data": [
    {
        "name": "abacus",
        "author": "admin",
        "word_id": "2",
        "category": "Education",
        "definitions": [
            {
                "rating": "Green",
                "defintion": "replace \"my pc\" asdf edited",
                "def_id": "53",
                "example": null,
                "author": "admin"
            },
            {
                "rating": "This definition is not rated yet.",
                "defintion": "my new definition of word abacus",
                "def_id": "7",
                "example": null,
                "author": "admin"
            },
            {
                "rating": "This definition is not rated yet.",
                "defintion": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea, tempore labore veritatis maxime beatae est incidunt consectetur adipisci dolore reiciendis. Nostrum fugiat cumque beatae voluptatum.",
                "def_id": "45",
                "example": null,
                "author": "admin"
            },
            {
                "rating": "This definition is not rated yet.",
                "defintion": "this sub def will rep abacus' \"venture capitalist\"",
                "def_id": "31",
                "example": null,
                "author": "admin"
            }
        ],
        "is_favourite": "Yes"
    }
]
})

my model are

Ext.define('Sencha.model.Menu', {
extend: 'Ext.data.Model',
config: {
    fields: [
        'name',
        'author',
        'word_id',
        'category',
      'data.definitions.definition'
    ],

    belongsTo: "Sencha.model.Contact"
}
});

Ext.define('Sencha.model.Contact', {
extend: 'Ext.data.Model',

requires: ['Sencha.model.Menu'],

config: {
    fields: [
        {name: 'status', mapping: 'status'},
        {name: 'message', mapping: 'message'},
        {name:'data', mapping: 'data'},
        {name: 'definitions', mapping: 'definitions.defintion'},
        {name: 'ratings', mapping: 'definitions.rating'},
       /* {name: 'definition', mapping: 'definitions'}*/
     /*{name: 'definition', mapping: 'data.definition.final_rating'}, json data     parsing My Favourite page and Today's word 65%*/
        

    ],
}
});

my store

Ext.define('Sencha.store.Contacts', {
extend: 'Ext.data.Store',

config: {
    model: 'Sencha.model.Contact',
    autoLoad: true,
    //sorters: 'name',
    grouper: {
        groupFn: function(record) {
            return record.get('name')[0];
        }
    }
}
});

My view

Ext.define("Sencha.view.Main", {
extend: 'Ext.tab.Panel',
requires: ['Ext.TitleBar', 'Sencha.view.Contacts'],

config: {
    tabBarPosition: 'bottom',

    items: [
        {
            title: 'Contacts',
            iconCls: 'home',

            xtype: 'contacts'
        }
    ]
}
});

![i have been able to do upto this][7]
Ext.define('Sencha.view.Contacts', {
extend: 'Ext.List',
xtype: 'contacts',

config: {
    title: 'Stores',
    cls: 'x-contacts',

    store: 'Contacts',
    itemTpl: [

        '<div>',
            '<h2><b>Hello</b></h2>',
            '<tpl for="data">',
                '<div> - {name}</div>',
                '<div> - {author}</div>',
                '<div> - {word_id}</div>',
                '<div> - {category}</div>',
               '<div> - {definitions}</div>',
               
            '</tpl>',
        '</div>'
    ].join('')
}
});

My output was supposed to be ![enter image description here][8]

Community
  • 1
  • 1
surhidamatya
  • 2,419
  • 32
  • 56

2 Answers2

1

I'm not sure what exactly you are trying to achieve, I rebuilt your application locally and am able to get this screen:

screenshot

I think the only major change I made was to the json:

    [
    {
        "accountInfo": {
            "expire_date": "2014-07-02 08:01:09",
            "subscribe_date": "2013-07-02 08:01:09",
            "time_remain": " 355 Days 20 Hours 47 Minutes",
            "status": "not expired"
        },
        "status": "TRUE",
        "message": "Todays Word",
        "data": [
            {
                "name": "abacus",
                "author": "admin",
                "word_id": "2",
                "category": "Education",
                "definitions": [
                    {
                        "rating": "Green",
                        "defintion": "replace \"my pc\" asdf edited",
                        "def_id": "53",
                        "example": null,
                        "author": "admin"
                    },
                    {
                        "rating": "This definition is not rated yet.",
                        "defintion": "my new definition of word abacus",
                        "def_id": "7",
                        "example": null,
                        "author": "admin"
                    },
                    {
                        "rating": "This definition is not rated yet.",
                        "defintion": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea, tempore labore veritatis maxime beatae est incidunt consectetur adipisci dolore reiciendis. Nostrum fugiat cumque beatae voluptatum.",
                        "def_id": "45",
                        "example": null,
                        "author": "admin"
                    },
                    {
                        "rating": "This definition is not rated yet.",
                        "defintion": "this sub def will rep abacus' \"venture capitalist\"",
                        "def_id": "31",
                        "example": null,
                        "author": "admin"
                    }
                ],
                "is_favourite": "Yes"
            }
        ]
    }
]

Give that a shot and let me know if you still have errors, or if you are looking for something else.

Good luck, Brad

bwags
  • 998
  • 9
  • 16
  • i too was able to get that value but i want to display definition i.e in palce of object object i want to display rating: green author: admin "definition: replace \"my pc\" asdf edited" – surhidamatya Jul 12 '13 at 03:28
0

ok, i found the answer and learned new thing. Don't panic when there is error:). I just added some extra tpl. Thanks to those who tried to help me. Sorry for the trouble.

Ext.define('Sencha.view.Contacts', {
extend: 'Ext.List',
xtype: 'contacts',

config: {
    title: 'Stores',
    cls: 'x-contacts',

    store: 'Contacts',
    itemTpl: [

        '<div>',
            '<h2><b>Hello</b></h2>',
            '<tpl for="data">',
                '<div> Status - {status}</div>',
                '<div> Author - {author}</div>',
                '<div> Word - {name}</div>',
                '<div> Category - {category}</div>',
                '<tpl for="definitions">',
                   '<div style="margin-left:100px;"> rating - {rating} </div>',
                    '<div style="margin-left:100px;">Definition: {defintion} </div>',
                     '<div style="margin-left:100px;">Author: {author} </div>',
               '</tpl>',
            '</tpl>',
        '</div>'
    ].join('')
}
});
surhidamatya
  • 2,419
  • 32
  • 56