PDA

View Full Version : Which Datastructures for JSON-Reader?



da_b0uncer
31 Oct 2011, 8:16 AM
Hello!

I want to use ExtJS with a http-api, which outputs JSON data lists, which look like this:


{
"rtrn": { "status": <someNumber>, "msg": "<someText>" },
"list": [ "<someText>", "<someText>", "<someText>", ...]
}

so I tried to configure it with:



...
reader: {
type: 'json',
root: 'list'
}
...


I get the right "amount" of records, but the reader wants an array of object other than string, so I don't know which "field" I have to use to get the string-content into the right place of a model.

lucasguaru
31 Oct 2011, 8:47 AM
You have to get it in this way:


{
"rtrn": { "status": <someNumber>, "msg": "<someText>" },
"list": [{"value" : "value 1"}, {"value" : "value 2"}]
}

In this way you can use the store in a grid or combo and set the field to be shown.

da_b0uncer
31 Oct 2011, 8:52 AM
ok, so I would have rewrite the server-output, so it causes more traffic with sensless data... strange but thanks anyway :)

lucasguaru
31 Oct 2011, 11:29 AM
I understand your point of view and agree with you.
I guess this is because it's in the json structure.