PDA

View Full Version : Question on JSON formatting - recent Sencha screencast



stoem
1 Mar 2012, 12:45 PM
I'm referring to Jason Johnston's recent screencast about working with data in Sencha Designer.
http://vimeo.com/37561290

Noob alert: I'm a Flex developer but new to Sencha's tools and concepts.

I got the screencast example working fine, no problem following it along. However I want to use ColdFusion to spit out recordsets as JSON, and CF's default JSON format is as follows:


{"COLUMNS":["ID","USERNAME","FIRSTNAME","LASTNAME","PASSWORD","ROLE","AVATAR","EMAIL","PHONE"],
"DATA":[["4","Jason","John","Doe","900150983cd24fb0d6963f7d28e17f72","10","","fake@email.com","07855815361"],["5","John","John","Doe","900150983cd24fb0d6963f7d28e17f72","10","","",""],["1","Stefan","Stefan","Richter","900150983cd24fb0d6963f7d28e17f72","10","","fake@email.com","077777777"]]}


This format does not match the one expected by my Reader (I am assuming the Reader is the piece that I need to modify to make the store understand my specific JSON flavour).

Any pointers here? I tried to specify rootProperty as DATA but that did not work. I am also unsure what the successProperty should be.
Or maybe it is my template settings that need editing? I'm using

<div>{FIRSTNAME} {LASTNAME} {PHONE}</div>
right now which worked for the tutorial's JSON format but not mine. I should point out that when I test the app using my CF generated JSON I still see 5 items in the list, but they are all blank.

Basically this noob needs some help :D

Thanks.

Stefan

aconran
1 Mar 2012, 8:21 PM
ColdFusion outputs things in array of arrays rather than JSON.

You want to use an ArrayReader along with your AjaxProxy. There was a bug that preventing you from using the two together but has since been resolved in Sencha Touch 2.0 RC2, (released last Wednesday Feb 22).

The designer is not running RC2 yet, it will be updated with the next build.

stoem
2 Mar 2012, 12:46 AM
Thanmks, I will wait until RC2 drops and then dig into ArrayReader.

Regards,

Stefan

stoem
28 Mar 2012, 12:44 AM
I just wanted to add: CF does output valid JSON - it's not simply a bunch of Arrays but it is a valid JSON object with a COLUMNS and DATA property. Therefore I'm not sure why I would need an ArrayReader?

Isn't it limitation of Touch to expect the JSON to be structured in a particular way, when the output from CF is perfectly a valid JSON object with valid syntax?

Stefan

aconran
28 Mar 2012, 7:16 AM
Sure, you can think of it that way... It's either in object (cf structs) format or array format.

bruhast
12 Jul 2012, 8:42 AM
Hi Stoem -

Check my response on this thread: http://www.sencha.com/forum/showthread.php?189147-Sencha-2-mvc-need-to-parse-cfc-returned-json-data

Hope it helps.