Mojo::JSON::Pointer - JSON Pointers
use Mojo::JSON::Pointer; my $pointer = Mojo::JSON::Pointer->new({foo => [23, 'bar']}); say $pointer->get('/foo/1'); say 'Contains "/foo".' if $pointer->contains('/foo');
Mojo::JSON::Pointer is a relaxed implementation of RFC 6901.
Mojo::JSON::Pointer implements the following attributes.
my $data = $pointer->data; $pointer = $pointer->data({foo => 'bar'});
Data to be processed.
Mojo::JSON::Pointer inherits all methods from Mojo::Base and implements the following new ones.
my $bool = $pointer->contains('/foo/1'); my $bool = $pointer->contains($data, '/foo/1');
Check if Perl data structure contains a value that can be identified with the given JSON Pointer, defaults to using "data".
# True $pointer->contains({'♥' => 'mojolicious'}, '/♥'); $pointer->contains({foo => 'bar', baz => [4, 5, 6]}, '/foo'); $pointer->contains({foo => 'bar', baz => [4, 5, 6]}, '/baz/2'); # False $pointer->contains({'♥' => 'mojolicious'}, '/☃'); $pointer->contains({foo => 'bar', baz => [4, 5, 6]}, '/bar'); $pointer->contains({foo => 'bar', baz => [4, 5, 6]}, '/baz/9');
my $value = $pointer->get('/foo/bar'); my $value = $pointer->get($data, '/foo/bar');
Extract value identified by the given JSON Pointer, defaults to using "data".
# "mojolicious" $pointer->get({'♥' => 'mojolicious'}, '/♥'); # "bar" $pointer->get({foo => 'bar', baz => [4, 5, 6]}, '/foo'); # "4" $pointer->get({foo => 'bar', baz => [4, 5, 6]}, '/baz/0'); # "6" $pointer->get({foo => 'bar', baz => [4, 5, 6]}, '/baz/2');
my $pointer = Mojo::JSON::Pointer->new; my $pointer = Mojo::JSON::Pointer->new({foo => 'bar'});
Build new Mojo::JSON::Pointer object.
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
To install Mojolicious, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious
CPAN shell
perl -MCPAN -e shell install Mojolicious
For more information on module installation, please visit the detailed CPAN module installation guide.