[dancer-users] JSON Serialiser

Sawyer X xsawyerx at gmail.com
Thu Jul 23 18:33:59 BST 2015


Hmm... I'm not sure why you're getting this problem.

Usually the problem people have is confusing routes that return HTML to
ones that return JSON and then expecting it to handle both in the same App
(which we removed for several reasons - as explained in blog posts, the
advent calendar, the mailing list, Github, and the changelog).

However, I'm not sure why *this* wouldn't work.

Can you reduce this to a test case? I would be happy to understand this
better.


On Sun, Jul 19, 2015 at 11:32 AM, Zahir Lalani <ZahirLalani at oliver.agency>
wrote:

> --From: dancer-users [mailto:dancer-users-bounces at dancer.pm] On Behalf Of
> Sawyer X
> --Sent: 19 July 2015 00:31
> --To: Perl Dancer users mailing list
> --Subject: Re: [dancer-users] JSON Serialiser
>
> --I don't understand this email. T abundance of HTML in your message is
> quite disruptive.
> ------
>
> My apologies for the confusion. Let me try again…..
>
> I had code which was working just fine two months ago. It relied on the
> automatic JSON deserialise + blessed objects. I was able to "return" a Moo
> object as a response to a REST request and the output would correctly show
> the json. So the basic format for this is:
>
> get '/xxxx' => sub {
>      return AnObject->new;
> };
>
> AnObject has TO_JSON implemented.
>
> I came back to this project after 2 months and found that it no longer
> worked - I would get an error of the form " Unrecognized response type from
> route". I found  a thread from April 15th which showed the same issue and a
> solution. (this is what I tried to include!). The solution was to wrap the
> response object in a hash as below:
>
> get '/xxxx' => sub {
>     return { result => AnObject->new };
> };
>
> My question is: which should be the correct way. My previous way worked
> and then something must have changed. Was the change deliberate? I have no
> issue with the solution above, I just want to understand whether this is
> the expected behaviour now.
>
> Z
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150723/b3cf9f00/attachment.html>


More information about the dancer-users mailing list