I just spent five minutes on RIAForge changing the search page to use JSON instead of XML. I know I've said this before, but you got to love the size differences. Before the change, the size of the XML packet downloaded was 152KB. With JSON it's down to 72KB.
For those who may view source - please note that I didn't really touch much else - so the code could be even better probably (using the Paged Data support instead of my manual paging for example).
I've blogged about how I integrate Model-Glue with AJAX before, but here is a quick recap. When I make an event that is meant to serve data up to an Ajax client, I first broadcast my message to get my data:
<message name="GetApprovedProjects"> <argument name="mode" value="short" /> </message>
I then broadcast a generic message:
<message name="ToJSON"> <argument name="viewstatekey" value="projects" /> </message>
My controller code for ToJSON does:
<cffunction name="toJSON" access="public" returnType="void" output="true"> <cfargument name="event" type="any"> <cfset var viewKey = arguments.event.getArgument("viewstatekey")> <cfset var data = ""> <cfset var json = "">
<cfif arguments.event.valueExists(viewkey)> <cfset data = arguments.event.getValue(viewkey)> <cfset json = serializeJSON(data,true)> </cfif>
<cfset arguments.event.setValue("json", json)> </cffunction>
So in case that isn't obvious - what it means is I can broadcast any message and just pass the results to a generic JSON converter. (The view just dumps out the JSON string.)