PDA

View Full Version : Does Sencha Touch support a JSON.NET deserializing with $ref ?



dusoft
22 Jul 2013, 5:38 AM
Hello!! I am using a .net WebApi project with JSON.NET ( Newtonsoft library) ... :( Yes, I knew that It is not the better but it's a customer requeriment..
I had some problems with a nested Json with model with HasMany associations, because the library serialize some properties as follows:




[{
"$id": "1",
"Code": "1",
"Name": "Model 1",
"Collection": [
{
"$id": "3",
"Cod": "4",
"Name": "Item 4"
},
{
"$id": "4",
"Cod": "5",
"Name": "Item 5"
}
]
},
{
"$id": "2",
"Code": "2",
"Name": "Model 2",
"Collection": [
{
"$ref": "3"
}
]
}
]


You can see that In the serialize process, it created the $id and $ref fields automatically, for do the reference to other object, for example the [$ref: "3"] is a shorcut to entity ["$id": "3"].


Can sencha deserialize associations with "$ref" ?? And load the associated fields (Model with HasMany association) using a simple store with related model?

Sencha should convert this:



...
"Collection": [
{
"$ref": "3"
}
]
...


to:



...
"Collection": [
{
"$id": "3",
"Cod": "4",
"Name": "Item 4"
}

]
...


I did a little sencha touch project with a store with AJAX proxy and a model.
I am using Architect 2.2.2 991 and Sencha touch 2.2.1 . (Latest version)

Best Regards!

mitchellsimoens
24 Jul 2013, 4:45 AM
Associations like that will not happen automatically. You would need to do the connection.

dusoft
24 Jul 2013, 5:42 AM
Thanks, I had this dude.