Hi All Just came across this previous message whilst debugging an issue: John Barrett john at jbrt.org <mailto:dancer-users%40dancer.pm?Subject=Re%3A%20%5Bdancer-users%5D%20JSON%20serializer%2C%0A%20returning%20object%20instances%20form%20route%20handlers%2C%20convert_blessed&In-Reply-To=%3C20150416102503.3b16541b%40rimmer.home.fuzzix.org%3E> Thu Apr 16 10:25:03 BST 2015 * Previous message: [dancer-users] JSON serializer, returning object instances form route handlers, convert_blessed<http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/004499.html> * Next message: [dancer-users] Dancer training at YAPC::NA<http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/004506.html> * Messages sorted by: [ date ]<http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/date.html#4505> [ thread ]<http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/thread.html#4505> [ subject ]<http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/subject.html#4505> [ author ]<http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/author.html#4505> ________________________________ On Wed, 15 Apr 2015 17:55:11 +0100 John Barrett <john at jbrt.org<http://lists.preshweb.co.uk/mailman/listinfo/dancer-users>> wrote:
get '/object' => sub {
AnObject->new;
};
Quick follow up on this, Wrapping the instance in a hashref constructor performs as expected: get '/object' => sub { { object => AnObject->new }; }; ...which I guess is what I should have been doing in the first place. Sorry for noise. There was no confirmation of the final message. I have the exact same issue - the return of an object used to work fine - the code I have was tested 2 months ago with no issues. We have of course been updating modules and dancer, and coming back to this project, the serialiser now gives the Route Exception error just like for John. I will test out his solution - can I get confirmation that this is indeed the way to properly handle it, or is this a bug? Zahir Lalani Head of Development & Architecture [cid:96F784CA-E917-4CC1-A9A9-96CBDA2AF2BC] 2 Tabernacle Street, London, EC2A 4LU m: +44 (0)7956 455168 t: +44 (0)203 142 3619 e: zahirlalani@oliver-marketing.com<mailto:zahirlalani@oliver-marketing.com> w: www.oliver-marketing.com<http://www.oliver-marketing.com/>
I don't understand this email. T abundance of HTML in your message is quite disruptive. You either did not include the actual error or the HTML is in the way. I'm not even sure what I'm reading, but it seems like you copy pasted your inbox and a message you received and a comment to that message. I'm not sure. Also, other than not including the error, you didn't really provide any context to this. What is this about? What would help is "this is my code and here is an error I received". Both are not present. :) Can you please fill in the blanks? On Fri, Jul 10, 2015 at 12:39 PM, Zahir Lalani <ZahirLalani@oliver.agency> wrote:
Hi All
Just came across this previous message whilst debugging an issue:
*John Barrett* john at jbrt.org <dancer-users%40dancer.pm?Subject=Re%3A%20%5Bdancer-users%5D%20JSON%20serializer%2C%0A%20returning%20object%20instances%20form%20route%20handlers%2C%20convert_blessed&In-Reply-To=%3C20150416102503.3b16541b%40rimmer.home.fuzzix.org%3E> *Thu Apr 16 10:25:03 BST 2015*
- Previous message: [dancer-users] JSON serializer, returning object instances form route handlers, convert_blessed <http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/004499.html> - Next message: [dancer-users] Dancer training at YAPC::NA <http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/004506.html> - *Messages sorted by:* [ date ] <http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/date.html#4505> [ thread ] <http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/thread.html#4505> [ subject ] <http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/subject.html#4505> [ author ] <http://lists.preshweb.co.uk/pipermail/dancer-users/2015-April/author.html#4505>
------------------------------
On Wed, 15 Apr 2015 17:55:11 +0100
John Barrett <john at jbrt.org <http://lists.preshweb.co.uk/mailman/listinfo/dancer-users>> wrote:
* get '/object' => sub {*
* AnObject->new;*
* };*
Quick follow up on this,
Wrapping the instance in a hashref constructor performs as expected:
get '/object' => sub {
{ object => AnObject->new };
};
...which I guess is what I should have been doing in the first place.
Sorry for noise.
There was no confirmation of the final message. I have the exact same issue – the return of an object used to work fine – the code I have was tested 2 months ago with no issues. We have of course been updating modules and dancer, and coming back to this project, the serialiser now gives the Route Exception error just like for John. I will test out his solution – can I get confirmation that this is indeed the way to properly handle it, or is this a bug?
*Zahir Lalani Head of Development & Architecture*
[image: cid:96F784CA-E917-4CC1-A9A9-96CBDA2AF2BC]
2 Tabernacle Street,
London, EC2A 4LU
m: +44 (0)7956 455168
t: +44 (0)203 142 3619
e: *zahirlalani@oliver-marketing.com <zahirlalani@oliver-marketing.com>*
w: www.oliver-marketing.com
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
--From: dancer-users [mailto:dancer-users-bounces@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
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@oliver.agency> wrote:
--From: dancer-users [mailto:dancer-users-bounces@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@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Yes will do. z Sent from my HTC ----- Reply message ----- From: "Sawyer X" <xsawyerx@gmail.com> To: "Perl Dancer users mailing list" <dancer-users@dancer.pm> 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 <ZahirLalani@oliver.agency<mailto:ZahirLalani@oliver.agency>> wrote: --From: dancer-users [mailto:dancer-users-bounces@dancer.pm<mailto:dancer-users-bounces@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@dancer.pm<mailto:dancer-users@dancer.pm> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
participants (2)
-
Sawyer X -
Zahir Lalani