ColdFusion Variable Name with brackets

风格不统一 提交于 2019-12-11 00:47:28

问题


I'm interacting with a webhook which provides a FORM struct with several variables containing brackets [ ] . How can I utilize these variables within CFML?

Example:

FORM.PAYLOAD[SITE][ID]

FORM is the struct PAYLOAD[SITE][ID] is the name of the variable within the FORM struct.

All help is greatly appreciated!


回答1:


I would rather suggest you to dump the form struct using cfdump like this-

<cfdump var = "#form#" />

and see if PAYLOAD[SITE][ID] is a key of form struct or only payload is the key.

If the whole PAYLOAD[SITE][ID] appears as a key in the dump, then as @matt suggested, you can utilize the variables like this-

<cfset payload_site_id = form["PAYLOAD[SITE][ID]"] />



回答2:


ColdFusion does not natively handle structs or arrays within a forms.

In 2007, Brian Kotek created a tool that do that processing.

In 2013, I created a tool that worked with the then current version of FW/1 . The latest version of that tool can be found at: https://github.com/jmohler1970/BS-4-CF/tree/master/framework

Last but not least, I put in a ticket into Adobe bugbase to add that functionality natively: https://bugbase.adobe.com/index.cfm?event=bug&id=4156093



来源:https://stackoverflow.com/questions/40034108/coldfusion-variable-name-with-brackets

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