thisOldDave
11/17/2022, 10:47 AMfoo=[1,2,3,4] -> /foo/[some array notation]
chris-schmitz
11/17/2022, 11:05 AM?foo=[1,2,3,4]
it will be seen as a string beginning with a square bracket.
This has nothing to do with ColdBox though, it's just the way URL params are handled.
You can try easily with a simple test page:
<cfdump var="#url#">
<cfoutput>#isArray( url.foo )#</cfoutput>
thisOldDave
11/17/2022, 12:40 PMcfvonner
11/17/2022, 5:17 PM/?foo=1&foo=2&foo=3&foo=4
and in your Application.cfc set this.sameFormFieldsAsArray = true
, then the incoming URL variable foo
should be an actual array ([1,2,3,4]
).cfvonner
11/17/2022, 5:22 PMfoo=[1,2,3,4]
would become foo=%5B1%2C2%2C3%2C4%5D
. CF should automatically decode that to a JSON string, which you could then use deserializeJSON
to convert to an array. This approach can be used for more complex data structures (like structs, arrays, or nested combinations of both).