JSON::T - transform JSON using JsonT
my $jsont = slurp('foo/bar.js');
my $input = slurp('foo/quux.json');
my $JSONT = JSON::T->new($jsont);
This module implements JsonT, a language for transforming JSON-like structures, analogous to XSLT in the XML world.
This module tries to provide a similar API to XML::Saxon::XSLT2.
will try to pick a working implementation for you.
parameters(param1=>$arg1, param2=>$arg2, ...)
Run the transformation. The input may be a JSON string, a JSON::JOM::Node or a native Perl nested arrayref/hashref structure, in which case it will be stringified using the JSON module's to_json function. The output (return value) will be a string.
Like transform, but attempts to parse the output as a JSON string and return a native Perl arrayref/hashref structure. This method will fail if the output is not a JSON string.
Like UNIVERSAL's DOES method, but returns true for:
as an aid for polymorphism.
The following methods also exist for compatibility with XML::Saxon::XSLT2, but are mostly useless:
A function print_to_perl is provided which prints to Perl's STDOUT stream.
This one is optional to implement it. If you don't implement it, then users will get a warning message if they try to call parameters on your subclass.
Will be passed an object ($self) and a hash of parameters, using the following format:
name1 => 'value1',
name2 => [ type2 => 'value2' ],
name3 => [ type3 => 'value3', hint => 'hint value' ],
This should have the effect of setting:
var name1 = 'value1';
var name2 = 'value2';
var name3 = 'value3';
You are unlikely to need to do anything else when subclassing.
If you wish JSON::T->new to know about your subclass, then push its name onto @JSON::T::Implementations.
Please report any bugs to http://rt.cpan.org/.
Related modules: JSON, JSON::Path, JSON::GRDDL, JSON::Hyper, JSON::Schema.
JOM version: JSON::JOM, JSON::JOM::Plugins::JsonT.
Toby Inkster <firstname.lastname@example.org>.
Copyright 2006 Stefan Goessner.
Copyright 2008-2011, 2013-2014 Toby Inkster.
Licensed under the Lesser GPL: http://creativecommons.org/licenses/LGPL/2.1/.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install JSON::T, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.