ColdFusion Variable Name with brackets

2019-07-23 12:26发布

问题:

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