[Catalyst] Using JSON

J. Shirley jshirley at gmail.com
Tue Apr 14 21:11:18 GMT 2009


On Wed, Apr 15, 2009 at 4:19 AM, W. Tyler Gee <geekout at gmail.com> wrote:

> I think the recommended module would be Catalyst::View::JSON and if you
> want to change anything you just plug in a different driver via the config
> rather than worrying about altering the View itself.
> ~Tyler
>
> 2009/4/14 Octavian R=E2=BAni=FE=E3 <orasnita at gmail.com>
>
>> Hi,
>>
>>
>> What's the recommended module for getting a JSON request and creating a
>> JSON response in a Catalyst app?
>> (I want to use them with JQuery.)
>>
>> Thanks.
>>
>> Octavian
>>
>>
>> _______________________________________________
>> 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/
>>
>
>
> _______________________________________________
> 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/
>
>

The other solutions above that don't have you using View::JSON are wrong.

Use Catalyst::View::JSON.

Do not use other things (unless it is REST, in which case let it delegate to
Catalyst::Action::Serialize::JSON, but in the future I am hoping to patch
this to use Catalyst::View::JSON as well) as that is not the right way to do
it.

Additionally, View::JSON has a lot of use cases and maturity baked into it.
It handles utf8 properly, and many other little things.

Doing it yourself is wrong, and unless you copied the serialization code
from View::JSON, you are missing something.

(The Catalyst::Plugin::Server mechanism is fine if you are using that, too.
For RPC stuff you do need to alter the request cycle slightly, however I
would hope it still uses Catalyst::View::JSON)

-J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090415/722a9=
bd1/attachment.htm


More information about the Catalyst mailing list