line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
37
|
|
|
37
|
|
14744
|
use strict; |
|
37
|
|
|
|
|
136
|
|
|
37
|
|
|
|
|
1091
|
|
3
|
37
|
|
|
37
|
|
235
|
use warnings; |
|
37
|
|
|
|
|
95
|
|
|
37
|
|
|
|
|
1439
|
|
4
|
|
|
|
|
|
|
|
5
|
37
|
|
|
37
|
|
244
|
package WWW::Shopify::Liquid::Filter::JSON; use base 'WWW::Shopify::Liquid::Filter'; |
|
37
|
|
|
|
|
102
|
|
|
37
|
|
|
|
|
3781
|
|
6
|
37
|
|
|
37
|
|
12866
|
use JSON qw(encode_json decode_json from_json); |
|
37
|
|
|
|
|
234920
|
|
|
37
|
|
|
|
|
323
|
|
7
|
37
|
|
|
37
|
|
7088
|
use Scalar::Util qw(blessed isweak); |
|
37
|
|
|
|
|
105
|
|
|
37
|
|
|
|
|
2617
|
|
8
|
37
|
|
|
37
|
|
281
|
use Clone qw(clone); |
|
37
|
|
|
|
|
110
|
|
|
37
|
|
|
|
|
13448
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub walk_data { |
11
|
9
|
|
|
9
|
0
|
26
|
my ($self) = @_; |
12
|
9
|
100
|
100
|
|
|
92
|
if (ref($self) && ref($self) eq "ARRAY" && !isweak($self)) { |
|
|
100
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
13
|
3
|
|
|
|
|
30
|
$self->[$_] = walk_data($self->[$_]) for (0..int(@$self)-1); |
14
|
|
|
|
|
|
|
} elsif (ref($self) && ref($self) eq "HASH" && !isweak($self)) { |
15
|
1
|
|
|
|
|
10
|
$self->{$_} = walk_data($self->{$_}) for (keys(%$self)); |
16
|
|
|
|
|
|
|
} |
17
|
9
|
100
|
66
|
|
|
198
|
return defined $self && blessed($self) && $self->isa('DateTime') ? $self->iso8601 : $self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub operate { |
21
|
|
|
|
|
|
|
# We allow decoding with this filter as well. |
22
|
4
|
100
|
66
|
4
|
0
|
92
|
if (defined $_[2] && !ref($_[2]) && length($_[2]) >= 2) { |
|
|
|
66
|
|
|
|
|
23
|
1
|
|
|
|
|
3
|
my $object = eval { from_json($_[2]) }; |
|
1
|
|
|
|
|
7
|
|
24
|
1
|
50
|
|
|
|
252
|
return $object if !$@; |
25
|
|
|
|
|
|
|
} |
26
|
3
|
50
|
33
|
|
|
421
|
my $object = $_[2] ? (blessed($_[2]) && $_[2]->isa('WWW::Shopify::Model::Item') ? WWW::Shopify::Liquid->liquify_item($_[2]) : walk_data(clone($_[2]))) : $_[2]; |
|
|
50
|
|
|
|
|
|
27
|
3
|
50
|
33
|
|
|
129
|
return defined $object && ref($object) ? JSON->new->allow_blessed(1)->encode($object) : '{}'; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |