[Coldbox 3.8.5] How to get JSON into Request Collection?

I’m trying to build a REST api that accepts a JSON string via a POST. My question is, how do I parse the JSON and get the object/properties into the Request Collection in my REST handler?

If anyone can point me in the right direction, I would appreciate it.

Thank you.
-Chris

Have you read this page?

http://wiki.coldbox.org/wiki/Projects:Relax.cfm

Can you try this:

var dataIn = event.getHTTPContent( json=true );

That will return a struct back already parsed as JSON.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

I made this happen with the following code:

`

<cfset requestBody = toString( getHttpRequestData().content )>
<cfif len(#requestBody#)>

<cfif StructKeyExists(RequestObj,‘Fax’)>


<cfset structAppend( rc, requestObj)>

`

It’s worth noting, that code cannot be unit tested, but the snipped I suggested can be since it allows you to mock the incoming data in the request collection.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com