line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
16603
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
56
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package App::JSON::to; |
5
|
|
|
|
|
|
|
# ABSTRACT: Convert JSON data to various formats |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.000'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
414
|
use JSON::MaybeXS qw; |
|
1
|
|
|
|
|
6898
|
|
|
1
|
|
|
|
|
380
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub run |
12
|
|
|
|
|
|
|
{ |
13
|
4
|
|
|
4
|
0
|
2727
|
my ($to, @args) = @_; |
14
|
4
|
|
|
|
|
9
|
$to = lc $to; |
15
|
|
|
|
|
|
|
|
16
|
4
|
50
|
|
|
|
12
|
die "missing target format\n" unless defined $to; |
17
|
|
|
|
|
|
|
die "invalid target format '$to'\n" |
18
|
4
|
50
|
33
|
|
|
26
|
unless $to =~ /\A[a-z]+\z/ && eval { require "App/JSON/to/$to.pm"; 1 }; |
|
4
|
|
|
|
|
827
|
|
|
4
|
|
|
|
|
24
|
|
19
|
4
|
|
|
|
|
10
|
my $class = __PACKAGE__ . '::' . $to; |
20
|
4
|
50
|
|
|
|
41
|
my $obj = $class->can('new') ? $class->new : $class; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# TODO parse options |
23
|
|
|
|
|
|
|
# GetOptions($obj->options); |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
14
|
binmode(STDIN, ':raw'); |
26
|
4
|
|
|
|
|
6
|
my $data = decode_json do { local $/; }; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
39
|
|
27
|
|
|
|
|
|
|
|
28
|
4
|
100
|
|
|
|
19
|
if (my $enc_meth = $obj->can('encoding')) { |
29
|
1
|
|
|
1
|
|
5
|
binmode(STDOUT, ':encoding('.$obj->$enc_meth().')'); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
6
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
9151
|
print $obj->dump($data); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
__END__ |