in reply to Dancer2: config UTF8 for JSON serializer from code
Hi Vlad, you can customize the serializer in the application package by setting the engine config first, then the serializer option:
Output in browser when requesting /config is something like:# in MyApp::Controller use Dancer2; set engines => { serializer => { JSON => { pretty => 1, allow_blessed => 1, canonical => 0, utf8 => 1, }, }, }; set serializer => 'JSON'; get '/config' => sub { return config; };
Note that, oddly, the config shows the value of serializer as null, but as the format of the output shows, the settings are being implemented.{ "apphandler" : "PSGI", # bunch of stuff snipped ... "engines" : { "serializer" : { "JSON" : { "utf8" : 1, "canonical" : 0, "allow_blessed" : 1, "pretty" : 1 } } }, "serializer" : null, "static_handler" : 1, "host" : "0.0.0.0" }
Hope this helps!
|
|---|