Coldfusion 10 returnformat =&"JSON&"添加字符 [英] Coldfusion 10 returnformat="JSON" adding characters

查看:75
本文介绍了Coldfusion 10 returnformat =&"JSON&"添加字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序正在从CF8转换为CF10,并且我的一些远程CFC上返回的数据应该是JSON现在失败了,因为似乎在前面添加了"//"返回的数据.例如,这是一个返回的结构的输出:

 //{"SUCCESS":true,"ERRORS":[],"DATA":{"COLUMNS":["AUTHRESULT","SPID","EMAIL","RID"],"DATA:[[true,361541," user@domain.com,"]]}} 

在CF8服务器上通过相同的CFC运行的相同功能给出:

  {"ERRORS":[],"SUCCESS":true,"DATA":{"COLUMNS":["AUTHRESULT","SPID","EMAIL","RID"],"DATA":[[true,361541,"user@domain.com","]]}} 

代理所有请求的CFC确实具有returnFormat ="JSON"-但在proxyCFC或从proxyCFC扩展的CFC中都没有调用SerializeJSON().

我不确定处理此问题的最佳方法是什么.修剪掉响应中的"//"是可能的,但这似乎不是正确的".我需要在CF10端解决它,因为这些功能不仅在我们的应用程序中使用,而且在一些远程应用程序中也使用(一些通过http://帖子使用,一些通过jQuery Ajax调用).

解决方案

这是应用程序变量./p>

secureJSON -一个布尔值,用于指定是否在ColdFusion函数以JSON格式返回以响应远程调用而返回的值之前添加安全前缀.

默认值是管理员服务器设置">设置"页面中的前缀序列化JSON"设置的值(默认为false).您可以在cffunction标记中覆盖此值.

secureJSONPrefix -如果secureJSON设置为true,则在ColdFusion函数以JSON格式返回的值前面放置的安全前缀,以响应远程调用.>

默认值是管理员服务器设置">设置"页面中的前缀序列化JSON"设置的值(默认为//,即JavaScript注释字符).

I have an app that I'm working on converting from CF8 to CF10 and some of my remote CFCs where the data coming back should be JSON are now failing because there seems to be a "//" pre-pended to the returned data. For example here's an output of a returned structure:

//{"SUCCESS":true,"ERRORS":[],"DATA":{"COLUMNS":["AUTHRESULT","SPID","EMAIL","RID"],"DATA":[[true,361541,"user@domain.com",""]]}} 

The same function run through the same CFC on the CF8 server gives:

{"ERRORS":[],"SUCCESS":true,"DATA":{"COLUMNS":["AUTHRESULT","SPID","EMAIL","RID"],"DATA":[[true,361541,"user@domain.com",""]]}} 

The CFC that proxies all requests does have returnFormat="JSON" - but there is no SerializeJSON() being called in either the proxyCFC or the CFC that is extended from proxyCFC.

I'm not sure what's the best way to handle this. Trimming off the '//' in the response would be possible but it doesn't seem "right". I need to address it on the CF10 end of things because these functions are in use not only in our app, but some remote apps as well (and some are through http:// posts and some are through jQuery Ajax calls).

解决方案

That is a server side setting in the ColdFusion admin, under settings. Prefix serialized JSON with. It is enabled by default for security. Protects web services, which return JSON data from cross-site scripting attacks by prefixing serialized JSON strings with a custom prefix.. Perhaps you had turned this off on your ColdFusion 8 server. I do not recommend turning it off though.

See this post from Raymond Camden - Handling JSON with prefixes in jQuery and jQueryUI

NOTE: this setting can also be set per-application by setting secureJSON and secureJSONPrefix in your Application.cfc file. See the documentation about that here - Application variables.

secureJSON - A Boolean value that specifies whether to add a security prefix in front of the value that a ColdFusion function returns in JSON-format in response to a remote call.

The default value is the value of the Prefix serialized JSON setting in the Administrator Server Settings > Settings page (which defaults to false). You can override this value in the cffunction tag.

secureJSONPrefix - The security prefix to put in front of the value that a ColdFusion function returns in JSON-format in response to a remote call if the secureJSON setting is true.

The default value is the value of the Prefix serialized JSON setting in the Administrator Server Settings > Settings page (which defaults to //, the JavaScript comment character).

这篇关于Coldfusion 10 returnformat =&"JSON&"添加字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆