| Template-Plugin-SimpleJson documentation | Contained in the Template-Plugin-SimpleJson distribution. |
Template::Plugin::SimpleJson - Simple JSON methods for Template Toolkit
[% USE SimpleJson %] [% scalar = SimpleJson.fromJson(json_text) %] [% text = SimpleJson.toJson(scalar) %]
This module implements some methods to manipulate json string, using JSON module
Converts a json string to a perl scalar
Converts a perl scalar to a json string
Fabio Masini <fabio.masini@gmail.com>
Copyright (C) 2009 Fabio Masini
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Template-Plugin-SimpleJson documentation | Contained in the Template-Plugin-SimpleJson distribution. |
package Template::Plugin::SimpleJson; use 5.006; use strict; our $VERSION = '0.01'; use Template::Plugin; use base qw( Template::Plugin ); use JSON; sub load { my $class = shift; my $context = shift; return $class; } sub new { my $class = shift; my $context = shift; my $self = bless { '_CONTEXT' => $context, }, $class; return $self; } sub fromJson{ my $self = shift; my $jsonText = shift; return from_json($jsonText); } sub toJson{ my $self = shift; my $o = shift; return to_json($o); } 1; __END__