NAME

Acrux::Pointer - The Acrux pointer

SYNOPSIS

use Acrux::Pointer;

my $pointer = Acrux::Pointer->new(data => {foo => [123, 'bar']});

say $pointer->get('/foo/1');
say 'Contains "/foo".' if $pointer->contains('/foo');

DESCRIPTION

This class is an implementation of RFC 6901 for perl hash-structures

new

my $pointer = Acrux::Pointer->new;
my $pointer = Acrux::Pointer->new(data => {foo => 'bar'});

Build new Acrux::Pointer object

ATTRIBUTES

This class implements the following attributes

data

my $data = $pointer->data;
$pointer = $pointer->data({foo => 'bar'});

Data structure to be processed

METHODS

This class implements the following methods

contains

my $bool = $pointer->contains('/foo/1');

Check if "data" contains a value that can be identified with the given pointer

get

my $value = $pointer->get('/foo/bar');

Extract value from "data" identified by the given pointer

# "just a string"
Acrux::Pointer->new(data => 'just a string')->get();

# "bar"
Acrux::Pointer->new(data => {foo => 'bar', baz => [4, 5, 6]})->get('/foo');

# "4"
Acrux::Pointer->new(data => {foo => 'bar', baz => [4, 5, 6]})->get('/baz/0');

# "6"
Acrux::Pointer->new(data => {foo => 'bar', baz => [4, 5, 6]})->get('/baz/2');

HISTORY

See Changes file

TO DO

See TODO file

SEE ALSO

Mojo::JSON::Pointer

AUTHOR

Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2024 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/