Skip to content

Commit

Permalink
mention that JSON Pointers use fragment identifier representation
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 3, 2013
1 parent 8bad5a2 commit 602eaef
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/Mojo/JSON/Pointer.pm
Expand Up @@ -56,30 +56,31 @@ L<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.
JSON Pointer in fragment identifier representation.
# True
$pointer->contains({foo => 'bar', baz => [4, 5, 6]}, '/foo');
$pointer->contains({foo => 'bar', baz => [4, 5, 6]}, '/baz/2');
$pointer->contains({'fo o' => 'bar', baz => [4, 5, 6]}, '/fo%20o');
$pointer->contains({'fo o' => 'bar', baz => [4, 5, 6]}, '/baz/2');
# False
$pointer->contains({foo => 'bar', baz => [4, 5, 6]}, '/bar');
$pointer->contains({foo => 'bar', baz => [4, 5, 6]}, '/baz/9');
$pointer->contains({'fo o' => 'bar', baz => [4, 5, 6]}, '/bar');
$pointer->contains({'fo o' => 'bar', baz => [4, 5, 6]}, '/baz/9');
=head2 get
my $value = $pointer->get($data, '/foo/bar');
Extract value identified by the given JSON Pointer.
Extract value identified by the given JSON Pointer in fragment identifier
representation.
# "bar"
$pointer->get({foo => 'bar', baz => [4, 5, 6]}, '/foo');
$pointer->get({'fo o' => 'bar', baz => [4, 5, 6]}, '/fo%20o');
# "4"
$pointer->get({foo => 'bar', baz => [4, 5, 6]}, '/baz/0');
$pointer->get({'fo o' => 'bar', baz => [4, 5, 6]}, '/baz/0');
# "6"
$pointer->get({foo => 'bar', baz => [4, 5, 6]}, '/baz/2');
$pointer->get({'fo o' => 'bar', baz => [4, 5, 6]}, '/baz/2');
=head1 SEE ALSO
Expand Down

0 comments on commit 602eaef

Please sign in to comment.