在ColdFusion中返回JSON数据作为响应

Rou*_*oul 6 coldfusion json

我在ICIMS API工作.我需要在ICIMS服务器的cfm页面调用中返回JSON数据和标题中的一些特定数据.

这里的回应应该是:

响应工作流状态将PUSH事件更改为平台:

HTTP/1.1 303 See Other
Location: http://xx.xx.xx.xx:8085/selectpackage?systemHash=101
Content-Type: application/json
{
"userMessage":"Confirm or modify package.",
}
Run Code Online (Sandbox Code Playgroud)

提前致谢.

回答:

> <cfset contentString = '{"userMessage": "Confirm or modify package."}'
> />
> 
> <cfheader name="Location"
> value="http://xx.xx.xx.xx:8085/selectpackage?systemHash=101" />
>     <cfcontent type="application/json" variable="#toBinary( toBase64( contentString ) )#" />
Run Code Online (Sandbox Code Playgroud)

Ale*_*ban 10

<cfheader 
    statusCode = "303"
    statusText = "See Other">

<cfheader 
    name="Location" 
    value="http://xx.xx.xx.xx:8085/selectpackage?systemHash=101">

<cfheader 
    name="Content-Type" 
    value="application/json">

<cfset foo = structNew()>
<cfset foo["userMessage"] = "Confirm or modify package.">

<cfoutput>#serializeJSON(foo)#</cfoutput>  
Run Code Online (Sandbox Code Playgroud)