Mojo::J...:Pointer(3)
π Mojo::JSON::Pointer(3) β aka JSON Pointers, bestie
So this is the manual page for Mojo::JSON::Pointer, straight out of the User Contributed Perl Documentation section of your friendly local manpages. Yes, the page title is truncated to Mojo::J...:Pointer(3) because manpages are dramatic like that, but the real one is Mojo::JSON::Pointer. Slaaay. β¨
π¦ NAME
Mojo::JSON::Pointer β literally just JSON Pointers, no cap.
πΈ SYNOPSIS
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');
That's the whole vibe. Build a pointer-ish object over some data, then get stuff out of it with a path string, or contains to vibe-check whether a path even exists. π«Ά
π DESCRIPTION
Mojo::JSON::Pointer is an implementation of RFC 6901 <https://tools.ietf.org/html/rfc6901>. That's the spec, bestie β it's the whole personality of this module and it's iconic for it.
β¨ ATTRIBUTES β¨
Mojo::JSON::Pointer implements the following attributes. Obsessed with how short this list is, honestly.
π data
my $data = $pointer->data;
$pointer = $pointer->data({foo => 'bar'});
The data structure to be processed β like, the actual thing you're poking at with your pointers. Get it, set it, live your truth. π
π METHODS π
Mojo::JSON::Pointer inherits all methods from Mojo::Base and implements the following new ones. Main character energy only for the ones listed below.
π contains
my $bool = $pointer->contains('/foo/1');
Check if data contains a value that can be identified with the given JSON Pointer. You get a boolean back. That's it, that's the whole method. π
# True
Mojo::JSON::Pointer->new('just a string')->contains('');
Mojo::JSON::Pointer->new({'β₯' => 'mojolicious'})->contains('/β₯');
Mojo::JSON::Pointer->new({foo => 'bar', baz => [4, 5]})->contains('/foo');
Mojo::JSON::Pointer->new({foo => 'bar', baz => [4, 5]})->contains('/baz/1');
# False
Mojo::JSON::Pointer->new({'β₯' => 'mojolicious'})->contains('/β');
Mojo::JSON::Pointer->new({foo => 'bar', baz => [4, 5]})->contains('/bar');
Mojo::JSON::Pointer->new({foo => 'bar', baz => [4, 5]})->contains('/baz/9');
Notice the '' empty pointer on a plain string is true β the whole scalar is the value, okay? And '/β'? Not in there. Snowman said no. π
π§ get
my $value = $pointer->get('/foo/bar');
Extract a value from data identified by the given JSON Pointer. Fetched. Retrieved. Served. π₯
# "just a string"
Mojo::JSON::Pointer->new('just a string')->get('');
# "mojolicious"
Mojo::JSON::Pointer->new({'β₯' => 'mojolicious'})->get('/β₯');
# "bar"
Mojo::JSON::Pointer->new({foo => 'bar', baz => [4, 5, 6]})->get('/foo');
# "4"
Mojo::JSON::Pointer->new({foo => 'bar', baz => [4, 5, 6]})->get('/baz/0');
# "6"
Mojo::JSON::Pointer->new({foo => 'bar', baz => [4, 5, 6]})->get('/baz/2');
Array indexes start at 0, so /baz/0 gives you 4 and /baz/2 gives you 6. Counting from zero is so real of arrays, fr fr. π¦
β new
my $pointer = Mojo::JSON::Pointer->new;
my $pointer = Mojo::JSON::Pointer->new({foo => 'bar'});
Build a new Mojo::JSON::Pointer object. Pass it data or don't β either way you're valid. πΈ
π SEE ALSO
MojoliciousMojolicious::Guides- <https://mojolicious.org>
Go read those, iykyk. π
π little reminder from your girl: the pointer strings are the whole API here. Get them wrong andcontainswill quietly hand you afalse. No error, no drama, just vibes denied. Check your paths. π
That's the page, bestie! Signing off from perl v5.42.0, dated 2026-07-15, in the Mojo::J...:Pointer(3) section. Periodt. ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Mojolicious 9.480.0-bp160.2.1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms