dorko has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I'm looking to turn a Perl data structure into a CGI query string.
There are several modules that turn query strings into data structures (eg CGI::Struct and CGI::State), but I need to do the opposite.
I've got something like this:
%hash = ( 'name' => 'test name', 'file_ids' => [ 1, 2 ], 'sub' => { 'name' => 'foo', 'message' => 'bar' }, );
And I want to turn it into something like this:
name=test+name&file_ids[]=1&file_ids[]=2&sub[name]=foo&sub[message]=bar
Even "data structure ==> JSON ==> query string" would be ok too.
I'm not finding any modules that do what I'm looking for. Does something like this exist?
Cheers,
Brent
-- Yeah, I'm a Delt.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Building a URL Query String from a Data Structure
by Your Mother (Archbishop) on Feb 09, 2016 at 19:15 UTC | |
by dorko (Prior) on Feb 11, 2016 at 16:29 UTC | |
Re: Building a URL Query String from a Data Structure
by neilwatson (Priest) on Feb 09, 2016 at 17:49 UTC | |
by dorko (Prior) on Feb 10, 2016 at 13:07 UTC | |
Re: Building a URL Query String from a Data Structure
by thomas895 (Deacon) on Feb 09, 2016 at 18:58 UTC | |
by dorko (Prior) on Feb 10, 2016 at 13:34 UTC | |
by thomas895 (Deacon) on Feb 10, 2016 at 23:21 UTC | |
by dorko (Prior) on Feb 11, 2016 at 16:23 UTC |
Back to
Seekers of Perl Wisdom