我一直在尝试创建一个数据结构,但我遇到了困难。我正在尝试创建这样的数据结构:
{
"vehicle": [
{
"inv_id": "123412",
"year": "2013",
"make": "Jeep",
"model": "Grand Cherokee"
},
{
"inv_id": "1224522",
"year": "2013",
"make": "Jeep",
"model": "Grand Cherokee"
}
]
}
这是我没有运气的尝试。
<cfset result["vehicle"] = []>
<cfoutput>
<cfloop query="qinv">
#arrayAppend("result.vehicle,{})#
<cfloop array="#result.vehicle#" index="i">
#structInsert(result.vehicle[i], "inventory_id", qInv.inventory_id)#
#structInsert(result.vehicle[i], "year", qInv.year)#
#structInsert(result.vehicle[i], "make", qInv.make)#
#structInsert(result.vehicle[i], "model", qInv.model)#
</cfloop>
</cfloop>
</cfoutput>
这会The value coldfusion.runtime.Struct cannot be converted to a number.
在第一行 structInsert 引发冷融合错误。
有什么建议么?