我正在尝试将以下内容序列化为 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/