[dancer-users] Serializer for Dancer2

Andrew Beverley andy at andybev.com
Sat Dec 20 17:55:15 GMT 2014


On 2014-12-20 05:44, Matthew Mallard wrote:
> I’ve been using serializer: "JSON" in my config.yml with no issues in
> Dancer2.  Today I updated Dancer2 to the latest and now the pages come
> out blank.  If I comment out the serializer line, things seem to
> return to normal (i.e. the pages render) - but my AJAX requests break.

I *think* there were some recent changes that altered the conditions 
that serialisation occurs (I've been meaning to look at this in more 
detail for my own project, but haven't had a chance).

Previously if you were using an auto-serialiser and returned a ref, then 
an attempt was made to serialise regardless of the request. Now 
serialisation will only take place if the request headers dictate such a 
response is appropriate.

I stand by to be corrected on any of the above!

> [project::WebApp:85745] core @2014-12-20 15:14:16> Failed to serialize
> the request: hash- or arrayref expected (not a simple scalar, use
> allow_nonref to allow this) at /perf/perl/lib/perl5/JSON.pm line 154.
> in (eval 754) l. 2

That said, your error implies that you are not returning a hash or array 
reference from your route? Have you tried dumping your return value to 
check?

Andy



More information about the dancer-users mailing list