Yes will do.

z

Sent from my HTC

----- Reply message -----
From: "Sawyer X" <[email protected]>
To: "Perl Dancer users mailing list" <[email protected]>
Subject: [dancer-users] JSON Serialiser
Date: Thu, Jul 23, 2015 22:34

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 
<[email protected]<mailto:[email protected]>> wrote:
--From: dancer-users 
[mailto:[email protected]<mailto:[email protected]>] 
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
[email protected]<mailto:[email protected]>
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

_______________________________________________
dancer-users mailing list
[email protected]
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

Reply via email to