line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Jmespath; |
2
|
2
|
|
|
2
|
|
11276
|
use strict; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
42
|
|
3
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
34
|
|
4
|
2
|
|
|
2
|
|
346
|
use Jmespath::Parser; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
15
|
|
5
|
1
|
|
|
1
|
|
273
|
use Jmespath::Visitor; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
6
|
1
|
|
|
1
|
|
583
|
use JSON qw(encode_json decode_json); |
|
1
|
|
|
|
|
9977
|
|
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
91
|
use Try::Tiny; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
8
|
1
|
|
|
1
|
|
7
|
use v5.14; |
|
1
|
|
|
|
|
2
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
1
|
|
|
1
|
|
463
|
use utf8; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
3
|
|
11
|
1
|
|
|
1
|
|
453
|
use Encode; |
|
1
|
|
|
|
|
6774
|
|
|
1
|
|
|
|
|
264
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub compile { |
14
|
0
|
|
|
0
|
0
|
|
my ( $class, $expression ) = @_; |
15
|
0
|
|
|
|
|
|
return Jmespath::Parser->new->parse( Encode::encode_utf8($expression) ); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub search { |
19
|
0
|
|
|
0
|
0
|
|
my ( $class, $expression, $data, $options ) = @_; |
20
|
0
|
|
|
|
|
|
my ($result); |
21
|
|
|
|
|
|
|
try { |
22
|
0
|
|
|
0
|
|
|
$result = Jmespath::Parser->new->parse( $expression ) |
23
|
|
|
|
|
|
|
->search( $data, $options ); |
24
|
|
|
|
|
|
|
} catch { |
25
|
0
|
|
|
0
|
|
|
$_->throw; |
26
|
0
|
|
|
|
|
|
}; |
27
|
0
|
0
|
|
|
|
|
return $result if not defined $result; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# JSON block result |
30
|
0
|
0
|
0
|
|
|
|
if ( ( ref ($result) eq 'HASH' ) or |
31
|
|
|
|
|
|
|
( ref ($result) eq 'ARRAY' ) ) { |
32
|
|
|
|
|
|
|
try { |
33
|
0
|
|
|
0
|
|
|
$result = JSON->new |
34
|
|
|
|
|
|
|
->utf8(1) |
35
|
|
|
|
|
|
|
->allow_nonref |
36
|
|
|
|
|
|
|
->space_after |
37
|
|
|
|
|
|
|
->allow_blessed(1) |
38
|
|
|
|
|
|
|
->convert_blessed(1) |
39
|
|
|
|
|
|
|
->encode( $result ); |
40
|
0
|
|
|
|
|
|
return $result; |
41
|
|
|
|
|
|
|
} catch { |
42
|
0
|
|
|
0
|
|
|
Jmespath::ValueException->new( message => "cannot encode" )->throw; |
43
|
0
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
if ( $result =~ /[0-9]+/ ) { |
47
|
0
|
|
|
|
|
|
return $result; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Unquoted string result |
51
|
0
|
0
|
0
|
|
|
|
if ( $ENV{JP_UNQUOTED} == 0 or |
52
|
|
|
|
|
|
|
not defined $ENV{JP_UNQUOTED} ) { |
53
|
0
|
|
|
|
|
|
$result = q{"} . $result . q{"}; |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
return $result; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Jmespath - Enabling easy querying for JSON structures. |
65
|
|
|
|
|
|
|
|