This file is indexed.

/usr/share/perl5/Mojo/JSON/Pointer.pm is in libmojolicious-perl 2.98+dfsg-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package Mojo::JSON::Pointer;
use Mojo::Base -base;

use Mojo::Util qw(decode url_unescape);
use Scalar::Util 'looks_like_number';

sub contains { shift->_pointer(1, @_) }
sub get      { shift->_pointer(0, @_) }

# "Google, even though you've enslaved half the world,
#  you're still a damn fine search engine."
sub _pointer {
  my ($self, $contains, $data, $pointer) = @_;

  # Parse pointer and walk data structure
  return unless $pointer =~ s!^/!!;
  for my $p (split '/', $pointer) {
    $p = decode('UTF-8', url_unescape $p);

    # Hash
    if (ref $data eq 'HASH' && exists $data->{$p}) { $data = $data->{$p} }

    # Array
    elsif (ref $data eq 'ARRAY' && looks_like_number($p) && @$data > $p) {
      $data = $data->[$p];
    }

    # Nothing
    else {return}
  }

  return $contains ? 1 : $data;
}

1;

=head1 NAME

Mojo::JSON::Pointer - JSON Pointers

=head1 SYNOPSIS

  use Mojo::JSON::Pointer;

  my $p = Mojo::JSON::Pointer->new;
  say $p->get({foo => [23, 'bar']}, '/foo/1');
  say 'Contains "/foo".' if $p->contains({foo => [23, 'bar']}, '/foo');

=head1 DESCRIPTION

L<Mojo::JSON::Pointer> implements JSON Pointers as described in
L<http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer>.

=head1 METHODS

=head2 C<contains>

  my $success = $p->contains($data, '/foo/1');

Check if data structure contains a value that can be identified with the given
JSON Pointer.

  # True
  $p->contains({foo => 'bar', baz => [4, 5, 6]}, '/foo');
  $p->contains({foo => 'bar', baz => [4, 5, 6]}, '/baz/2');

  # False
  $p->contains({foo => 'bar', baz => [4, 5, 6]}, '/bar');
  $p->contains({foo => 'bar', baz => [4, 5, 6]}, '/baz/9');

=head2 C<get>

  my $value = $p->get($data, '/foo/bar');

Extract value identified by the given JSON Pointer.

  # "bar"
  $p->get({foo => 'bar', baz => [4, 5, 6]}, '/foo');

  # "4"
  $p->get({foo => 'bar', baz => [4, 5, 6]}, '/baz/0');

  # "6"
  $p->get({foo => 'bar', baz => [4, 5, 6]}, '/baz/2');

=head1 SEE ALSO

L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.

=cut