Dancer2 JSON serialize failed to serialize application/x-www-form-urlencoded
What happened: Throw error trying to serialize application/x-www-form-urlencoded
Expected behavior: Not serialize application/x-www-form-urlencoded
Reproduction
$ dancer2 gen-app -d test_app
# edit test_app.pm
package test_app;
use Dancer2;
our $VERSION = '0.1';
+ set serializer => 'JSON'; # set JSON as default serializer
post '/' => sub {
return "Hello";
};
true;
$ plackup bin/app.psgi
Send a post request with application/x-www-form-urlencoded content
curl -X POST http://localhost:5000 \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'a=b'
# Result
{"title":"Error 400 - Bad Request","status":400,"message":"Failed to deserialize content: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before \"a=b\") at /home/dai/projects/Dancer2-example/test_app/local/lib/perl5/Dancer2/Serializer/JSON.pm line 47.\n"}
Perl version: 5.42.0
Dancer2 version: 2.0.1
Dancer2 JSON serialize failed to serialize application/x-www-form-urlencoded
What happened: Throw error trying to serialize
application/x-www-form-urlencodedExpected behavior: Not serialize
application/x-www-form-urlencodedReproduction
Send a post request with application/x-www-form-urlencoded content
Perl version: 5.42.0
Dancer2 version: 2.0.1