Coldfusion JSON序列化不一致 [英] Coldfusion JSON serialization inconsistency

查看:142
本文介绍了Coldfusion JSON序列化不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了以下组件:

<cfcomponent>

<cffunction name="test" returntype="struct" access="remote" returnformat="json">
    <cfset local.str = structNew()>

    <cfset str.a = "hello">
    <cfset str.b = 23>

    <cfreturn local.str>
</cffunction>

</cfcomponent>

当我在开发环境中运行时,我得到以下结果:

When I run this in my dev environment I get the following:

{"A":"hello","B":"23"}

在生产中,我得到:

{"A":"hello","B":23}

相同的代码,相同的CF版本,相同的JVM,任何人都知道为什么?

Same code, same CF version, same JVM, different results. Anybody know why?

推荐答案

看起来这是CF9的错误。不确定您如何从本地/生产版本获得不同的结果。详情请参阅这篇网志文章:

It appears that this is bug in CF9. Not sure how you are getting different results from your local / production version. See this blog post for a detailed discussion:

http://coldfusion.tcs.de/adobe-please-fix-coldfusion-serializejson/

您似乎有四个选项。


  1. 将您的代码修改为期望的字符串而不是数字

  2. 将您的CF服务器回滚到9.0 / li>
  3. 使用Railo代替Adobe CF

  4. 切换到其他JSON序列化程序。显然有两个名为CFJSON: http://cfjson.riaforge.org/ 和Dan Roberts的建议 http://www.epiphantastic.com/cfjson/

  1. Modify your code to expect strings instead of numbers
  2. Roll back your CF server to 9.0
  3. Use Railo instead of Adobe CF
  4. Switch to a different JSON serializer. Apparently there are two named CFJSON: http://cfjson.riaforge.org/ and Dan Roberts' suggestion http://www.epiphantastic.com/cfjson/

这篇关于Coldfusion JSON序列化不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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