I would use this instead

http://www.epiphantastic.com/cfjson/



-- 
Regards,
Andrew Scott
WebSite: http://www.andyscott.id.au/
Google+: http://plus.google.com/108193156965451149543



On Fri, Apr 20, 2012 at 6:39 PM, Edward Chanter <[email protected]> wrote:

>
> I've had similar problems to this when trying to serialise JSON for a
> jQuery
> plugin. The only solution I found that worked is detailed here:
>
> <!--- get the matches --->
> <cfquery name="q" datasource="#request.ds#">
> select product_id as value, product_title as label
> from products
> where product_title like <cfqueryparam value="%#url.term#%" />
> </cfquery>
>
> <!--- where we'll hold the data to convert to JSON --->
> <cfset data = [] />
>
> <cfoutput query="q">
>
>        <!--- create a new structure on each iteration, forcing lowercase
> keys --->
>        <cfset obj = {
>                "label" = label,
>                "value" = value
>        } />
>
>        <!--- push this match onto the array --->
>        <cfset arrayappend(data, obj) />
> </cfoutput>
>
> <!--- serialize the new structure --->
> <cfoutput>#serializeJSON(data)#</cfoutput>
>
> http://goo.gl/VGxlA
>
> Credit goes to Eric Hynds not me for this one.
>
> HTH


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:350810
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to