NAME

Template::Plugin::JSON - Adds a .json vmethod for all TT values.

VERSION

version 0.08

SYNOPSIS

        [% USE JSON ( pretty => 1 ) %];

        <script type="text/javascript">

                var foo = [% foo.json %];

        </script>

        or read in JSON

        [% USE JSON %]
        [% data = JSON.json_decode(json) %]
        [% data.thing %]

DESCRIPTION

This plugin provides a .json vmethod to all value types when loaded. You can also decode a json string back to a data structure.

It will load the JSON::MaybeXS module, which will use Cpanel::JSON::XS when possible and fall back to JSON::PP otherwise.

Any options on the USE line are passed through to the JSON object, much like "to_json" in Cpanel::JSON::XS.

SEE ALSO

JSON::MaybeXS, Template::Plugin

SUPPORT

Bugs may be submitted through the RT bug tracker (or bug-Template-Plugin-JSON@rt.cpan.org).

AUTHOR

יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>

CONTRIBUTORS

  • Neil Bowers <neil@bowers.com>

  • Karen Etheridge <ether@cpan.org>

  • Graham Barr <gbarr@pobox.com>

  • Leo Lapworth <leo@cuckoo.org>

  • perigrin <perigrin@cpan.org>

COPYRIGHT AND LICENCE

This software is Copyright (c) 2006 by Yuval Kogman.

This is free software, licensed under:

  The MIT (X11) License