JSON / CFML - Looping over an array of structs

后端 未结 2 1720
忘掉有多难
忘掉有多难 2021-01-22 20:58

I\'m testing an app called Barcode Scanner Terminal for my business; I\'m looking to use it as a replacement of sorts for a timeclock.

Employees can scan a barcode or QR

相关标签:
2条回答
  • 2021-01-22 21:04

    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.

    0 讨论(0)
  • 2021-01-22 21:13

    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=", "" ) )>
    
    0 讨论(0)
提交回复
热议问题