line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::JSON::Pointer; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
190946
|
use strict; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
50
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
39
|
|
5
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
6
|
2
|
|
|
2
|
|
62
|
use 5.008001; |
|
2
|
|
|
|
|
5
|
|
7
|
2
|
|
|
2
|
|
402
|
use JSON::MaybeXS qw( JSON ); |
|
2
|
|
|
|
|
4581
|
|
|
2
|
|
|
|
|
141
|
|
8
|
2
|
|
|
2
|
|
762
|
use Test2::Compare::JSON::Pointer; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
70
|
|
9
|
2
|
|
|
2
|
|
11
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT = qw( json ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Compare parts of JSON string to data structure using JSON pointers VERSION |
14
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub json ($;$) |
18
|
|
|
|
|
|
|
{ |
19
|
8
|
100
|
|
8
|
1
|
60097
|
my($pointer, $json) = @_ == 1 ? ('', $_[0]) : (@_); |
20
|
8
|
|
|
|
|
29
|
my @caller = caller; |
21
|
8
|
|
|
|
|
38
|
Test2::Compare::JSON::Pointer->new( |
22
|
|
|
|
|
|
|
file => $caller[1], |
23
|
|
|
|
|
|
|
lines => [$caller[2]], |
24
|
|
|
|
|
|
|
input => $json, |
25
|
|
|
|
|
|
|
pointer => $pointer, |
26
|
|
|
|
|
|
|
json => JSON->new->utf8(1), |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $count = 0; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
if(eval { require Test2::Tools::HTTP::Tx }) |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
return if $count++; |
35
|
|
|
|
|
|
|
require JSON::Pointer; |
36
|
|
|
|
|
|
|
Test2::Tools::HTTP::Tx->add_helper( |
37
|
|
|
|
|
|
|
'res.json' => sub { |
38
|
|
|
|
|
|
|
my($res, $pointer) = @_; |
39
|
|
|
|
|
|
|
my $json = JSON->new->utf8(1)->decode($res->decoded_content); |
40
|
|
|
|
|
|
|
if($pointer) |
41
|
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
|
$json = JSON::Pointer->get($json, $pointer); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
return $json; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |