使用 SerializeJSON 后 JSON 未正确输出

标签 json coldfusion coldfusion-9

我正在尝试将以下内容序列化为 JSON 并以两种方式检查输出,如下所示:

Line #13 : <cfset convertjson = SerializeJSON([ 
                                         { 
                                           "Id":"123",
                                           "Value":"1",
                                           "Desc":"Checking Description ",
                                           "Group":"1"

                                           }

                                        ])/>


Normal Output : <cfoutput>#convertjson#</cfoutput> 

<br/>

Dump Output: <cfdump var="#convertjson#">

我收到以下错误:
Invalid CFML construct found on line 13 at column 98.
ColdFusion was looking at the following text:

:

The CFML compiler was processing:

    An expression beginning with SerializeJSON, on line 11, column 26.This message is usually caused by a problem in the expressions structure.
    A cfset tag beginning on line 11, column 2.

但是我验证了我使用的 JSON,它是一个有效的 JSON。可能是什么问题呢?

最佳答案

ColdFusion 9 不支持使用 :创建结构时。尝试

<cfset convertjson = SerializeJSON([
  {
   Id = "123",
   value = "1",
   Desc = "Checking Description ",
   Group = "1"
  }
])/>

关于使用 SerializeJSON 后 JSON 未正确输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26146783/

相关文章:

javascript - 当重复时显示 json 对象数组的值一次

json - 如何在 Sublime Text 2 中有条件地设置文件夹

coldfusion - 使用相对路径扩展CFC

coldfusion - 在不知道服务器时间的情况下如何使用 DateDiff?

java - 使用 GSON 解析 JSON 对象列表

jquery - 使用 Jquery $getJSON 如何动态为 Url 参数后的 [data] 参数创建数据?

coldfusion - Canonicalize() 函数将字符转换为空格

java - 当我将 linkedin-j 与 javaloader 一起使用时,cfdump util 消失了

excel - Coldfusion SpreadsheetAddImage 函数不插入图像

json - 使用加号序列化 JSON 会导致无效的 JSON