in reply to POST array of hashes CGI
Thank you for your knowledge. However, if I serialize the data structure (in this case with JSON):
my $json = to_json( { myData => \@AoH } ); my $url = 'http://myweb.com/cgi-bin/memo.pl'; my $ua = LWP::UserAgent->new; my $request = POST($url, Content => [data=>[$json]]); $request->header( 'Content-Type' => 'application/json' ); my $response = $ua->request($request); print $response->content, "\n";
And change my cgi accordingly:
print header; my $q = CGI->new(); my $json = $q->param('data'); my $decoded_json = decode_json( $json );; print Dumper $decoded_json;
I get the following error: ">malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)")"
So there is still something I am missing in POST, any idea? Possible that I can not pass JSON data with "param"?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: POST array of hashes CGI
by 1nickt (Canon) on Nov 26, 2018 at 17:36 UTC | |
|
Re^2: POST array of hashes CGI
by hippo (Archbishop) on Nov 26, 2018 at 17:02 UTC | |
by IB2017 (Pilgrim) on Nov 26, 2018 at 17:07 UTC | |
by haukex (Archbishop) on Nov 26, 2018 at 17:36 UTC | |
by IB2017 (Pilgrim) on Nov 26, 2018 at 17:50 UTC |