PDA

View Full Version : JsonReader: dot in field's name or mapping



Daniil
29 May 2011, 3:01 PM
Hi everyone,

Please, could someone confirm: dot is allowed in field's name or mapping?

I found these two threads:
http://www.sencha.com/forum/showthread.php?62167
http://www.sencha.com/forum/showthread.php?83335

My test case is:

new Ext.data.JsonReader({
fields: [{
name: "test1",
mapping: "test1.test"
}, {
name: "test2",
mapping: "test2.test"
}, {
name: "test3",
mapping: "test3.test"
}]
})
and

[{
"test1.test": "test1",
"test2.test": "test2",
"test3.test": "test3"
}]

Thank you for your attention.

skirtle
29 May 2011, 3:34 PM
Dots are supported but your mapping syntax is incorrect. Mappings behave just like accessing properties on objects so you'd need to use square bracket if there's a dot:


new Ext.data.JsonReader({
fields: [{
name: "test1",
mapping: "['test1.test']"
}, {
name: "test2",
mapping: "['test2.test']"
}, {
name: "test3",
mapping: "['test3.test']"
}]
})

Daniil
29 May 2011, 3:57 PM
Oh, thank you.

I had to sleep before posting and try again at the morning:) I tried [test1.test] missing quote characters.

By the way, I have not got it working at my side, but, I believe, the problem is in our library, probably, server side related.

Thanks again!