JSON / CFML - Looping over an array of structs

隐身守侯 提交于 2019-12-02 00:11:29
M.Scherzer

It seems to me that you may well be able to access the value of "batch" directly as a part of the form scope. Assuming of course you are really receiving a post request.

So you may well be able to just do:

<cfif isDefined("form.batch")>
    <cfset aData = deSerializeJSON(trim(form.batch))>
    <cfdump var="#aData#">
</cfif>

So no need to look at the request body and no need to decode the response.

You either need to strip off the "batch=" or pass the entire thing into "evaluate()" which will set the array literal into a variable called batch. I would recommend the former option since the second could be exploited by malicious CFML content in the string.

<cfset arrayOfStructs = deserializeJson( replaceNoCase( decodedBody, "batch=", "" ) )>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!