JSON Body Vs Form Tags

10 views
Skip to first unread message

George

unread,
May 23, 2013, 10:17:37 PM5/23/13
to cfwh...@googlegroups.com
Following up to https://groups.google.com/forum/?fromgroups#!searchin/cfwheels/request$20body$20json$20/cfwheels/nGq3R204PDQ/WiT5IuriCYkJ

To see if there has been anyone to has implemented wheels to detect Content-Type: application/json and translate them into params?

Figured I would check in before I start building my own little thingy

George

unread,
May 23, 2013, 11:57:35 PM5/23/13
to cfwh...@googlegroups.com
Well if there was then I re-did the wheels. I wrote this to append JSON body to the params struct.

<cfcomponent extends="Wheels">

<cffunction name="init">

<cfset filters('convertJSONRequest')>

</cffunction>

<cffunction name="convertJSONRequest" access="private">

<cfif left(cgi.CONTENT_TYPE, 16) eq "application/json">

<cfparam name="params" default="#structNew()#">

<cfset var respbody = toString(getHttpRequestData().content)>

<cfif isjson(respbody)>

<cfset structAppend(params,deserializejson(respbody), false)>

</cfif>

</cfif>

</cffunction>

</cfcomponent>
Reply all
Reply to author
Forward
0 new messages