Files
svc-api-x/v1/taffy/core/nativeJsonDeserializer.cfc
T
2024-10-23 11:17:42 +03:00

22 lines
632 B
Plaintext

<cfcomponent extends="taffy.core.baseDeserializer">
<cffunction name="getFromJson" output="false" taffy:mime="application/json,text/json" hint="get data from json">
<cfargument name="body" hint="the textual request body" />
<cfset var data = 0 />
<cfset var response = {} />
<cfif not isJson(arguments.body)>
<cfset throwError(msg="Input JSON is not well formed", statusCode="400") />
</cfif>
<cfset data = deserializeJSON(arguments.body) />
<cfif not isStruct(data)>
<cfset response['_body'] = data />
<cfelse>
<cfset response = data />
</cfif>
<cfreturn response />
</cffunction>
</cfcomponent>