Mojo::JSON::Pointer - JSON Pointers
use Mojo::JSON::Pointer; my $pointer = Mojo::JSON::Pointer->new; say $pointer->get({foo => [23, 'bar']}, '/foo/1'); say 'Contains "/foo".' if $pointer->contains({foo => [23, 'bar']}, '/foo');
Mojo::JSON::Pointer is a relaxed implementation of RFC 6901.
my $success = $pointer->contains($data, '/foo/1');
Check if data structure contains a value that can be identified with the given JSON Pointer.
# 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($data, '/foo/bar');
Extract value identified by the given JSON Pointer.
# "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');
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.