Create a struct, with keys 'total' and 'items'. 'items' should be a
struct of structs, with each 'record' having an 'id' and 'title'. When
making the request of your cfc method, which should be set to return
this struct, include another parameter to the request: returnFormat = "JSON"
output="false">
...
Steve "Cutter" Blades
Adobe Certified Professional
Advanced Macromedia ColdFusion MX 7 Developer
Co-Author of "Learning Ext JS"
http://www.packtpub.com/learning-ext-js/book
_____________________________
http://blog.cutterscrossing.com
On 10/9/2009 10:39 AM, Stefan Richter wrote:
> Hi,
> Flex dev here - wannabe CF coder :-)
>
> I need to return some JSON to a Flash Lite client, the format I'd like
> to produce looks like this:
>
> {
> "total": "100",
> "items":
> [
> {"id": "0", "title": "Some Title"},
> {"id": "0", "title": "Some Title"},
> {"id": "0", "title": "Some Title"},
> {"id": "0", "title": "Some Title"},
> {"id": "0", "title": "Some Title"}
> ]
> }
>
> I have a query called 'list'.
> The 100 above should be my query's recordcount. The items are simply
> records in the query. I can't quite figure out how to
> 'manually' (maybe by looping over my query) produce the JSON output. I
> have see the JSON related functions and I can JSON-iny my query but
> then the format is not as above, but as CF choses.
>
> Right now I am running this code:
>
> SELECT fileid, entered_name from slides ORDER BY added DESC LIMIT
> #URL.start#,#URL.length#
>
>
>
> #jsondata#
>
> Which gives me the output here:
> http://www.sharemyslides.com/api/lite.cfm?action=list
>
>
> Any pointers appreciated.
>
> Cheers
>
> Stefan
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:327066
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4