Eden or anybody familiar on this subject, I tried your solution (REST + DBIx::..::HashRefInflator) but because my search retrieve more than one rows, I populated an array as per:
sub thing_GET { my ($self, $c) = @_; my @arr=(); my $rs = $c->model('DB::data)->search({}, { result_class => 'DBIx::Class::ResultClass::HashRefInflator', }); while (my $hashref = $rs->next) { push @arr,$hashref; } $self->status_ok( $c, entity => \@arr ); } Would you say that this is a valid approach? Or can I retrieve all data bu other means with the DBIx model? Thanks Roland -----Original Message----- From: Roland Philibert Sent: 13 September 2011 16:56 To: The elegant MVC web framework Subject: RE: [Catalyst] RE: DBIC <-> JSON conversion for AJAX 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:edencar...@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 <rphilib...@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@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. _______________________________________________ List: Catalyst@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. _______________________________________________ List: Catalyst@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/