PDA

View Full Version : problem with sjon



willyaguirre
25 Jul 2012, 8:26 AM
Ext.define('VE.store.Stusuario', {
extend: 'Ext.data.Store',
model: 'VE.model.Usuario',
autoLoad: true,

proxy: {
type: 'ajax',
url: 'http://localhost:8080/veronica/getAllUsers.html',
reader: {
type: 'json',
root: 'user',
successProperty: 'success'
}
}


});




I can't read this json




{

"users-result":{

"count":"4",
"users":[

{

"user":{

"username":"Willy",
"password":"1234",
"link":"/users/Willy"

}

},
{

"user":{

"username":"johny",
"password":"pachecho",
"link":"/users/johny"

}

},
{

"user":{

"username":"Henry1",
"password":"pass1",
"link":"/users/Henry1"

}

},
{

"user":{

"username":"Percy",
"password":"6666",
"link":"/users/Percy"

}

}

]

}

}

scottmartin
25 Jul 2012, 11:56 AM
I have to ask :D ... but I would like to make sure you are the bullets/numbers are your way indenting the json for this post?

Scott.

scottmartin
25 Jul 2012, 12:07 PM
Another question ... is this JSON created by you and is all nesting required?

simpler version ...



{
"total": "1",
"user": [
{
"id": "1",
"username": "Willy",
"password": "1234",
"link": "/users/willy"
}
]
}


Scott.

willyaguirre
25 Jul 2012, 12:33 PM
{

"users-result":{
"count":"4",
"users":[
{
"user":{
"username":"Willy",
"password":"1234",
"link":"/users/Willy"
}
},
{
"user":{
"username":"johny",
"password":"pachecho",
"link":"/users/johny"
}
},
{
"user":{
"username":"Henry1",
"password":"pass1",
"link":"/users/Henry1"
}
},
{
"user":{
"username":"Percy",
"password":"6666",
"link":"/users/Percy"
}
}
]
}

}



I am trying to get "user"



Ext.define('VE.model.Usuario', {
extend: 'Ext.data.Model',
//fields: ['nombre','pass']
fields: ['username','password']
});

scottmartin
25 Jul 2012, 12:59 PM
Have a look at the 'Loading Nested Data' section:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.reader.Reader

Scott.