[Catalyst] RE: DBIC <-> JSON conversion for AJAX
Roland Philibert
rphilibert at aptina.com
Tue Sep 13 15:56:27 GMT 2011
Eden> Then if you ask for a Content-Type of application/json you'll get
JSON from that in your response.
I would do that by adding to the REST controller:
sub end :Private {
my ($self, $c) = @_;
$c->forward("View::JSON");
}
Is that correct?
-----Original Message-----
From: Eden Cardim [mailto:edencardim at gmail.com]
Sent: 12 September 2011 21:31
To: The elegant MVC web framework
Subject: Re: [Catalyst] RE: DBIC <-> JSON conversion for AJAX
>>>>> "Roland" == Roland Philibert <rphilibert at aptina.com> writes:
Roland> Thanks all for your suggestions so far. I was I guess on
Roland> the right track with JSON:XS but I had also seen REST but so
Roland> far I am still unsure as what the best way to go
Catalyst::Controller::REST + DBIx::Class::ResultClass::HashRefInflator
works pretty well:
$self->status_ok(
$c,
entity => $rs->search({}, {
result_class => 'DBIx::Class::ResultClass::HashRefInflator'
})->next
);
Then if you ask for a Content-Type of application/json you'll get JSON
from that in your response.
--
Eden Cardim
Code Monkey http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment
platform?
http://blog.edencardim.com/
http://www.shadowcat.co.uk/servers/
http://twitter.com/#!/edenc
_______________________________________________
List: Catalyst at lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive:
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
Aptina (UK) Limited, Century Court, Millennium Way, Bracknell, Berkshire, RG12 2XT. Registered in England No. 06570543.
This e-mail and any attachments contain confidential information and are solely for the review and use of the intended recipient. If you have received this e-mail in error, please notify the sender and destroy this e-mail and any copies.
More information about the Catalyst
mailing list