Coldfusion: How to pass struct and array in a URL

Share this post:

A user just asked:

I need to pass my array to a webserver. But somehow, the array passed with cfhttp throws an error. Please help

You can not pass a structure or an array in a URL as they are complex values and Coldfusion does not have a way to convert them to simple string values (this is what you need to pass in a URL).

The only way to pass complex values is to serialize the Coldfusion struct or array for the URL. Fortunately, Coldfusion has a built in function called “SerializeJSON” to create a simple string. On the other hand, you can convert the simple string back to a struct or array with “DeserializeJSON”.

Here is a simple example how to pass a 2 dimensional array with cfhttp:

Over 10 years in business.

Self-funded. No investors. No bullshit.

More than 3,000 customers worldwide.

Helpmonks - no bullshit customer engagement service

Growth starts with action

Empower your team and delight your customers.

Helpmonks - email management for small businesses