line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::OptimalQuery::JSON; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
744
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
4
|
no warnings qw( uninitialized ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
3
|
use base 'CGI::OptimalQuery::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
7
|
1
|
|
|
1
|
|
5
|
use CGI(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
12
|
|
8
|
1
|
|
|
1
|
|
4
|
use JSON::XS(); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
156
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub output { |
11
|
0
|
|
|
0
|
0
|
|
my $o = shift; |
12
|
0
|
|
|
|
|
|
my $title = $o->{schema}->{title}; |
13
|
0
|
|
|
|
|
|
$title =~ s/\W//g; |
14
|
0
|
|
|
|
|
|
my @t = localtime; |
15
|
0
|
|
|
|
|
|
$title .= '_'.($t[5] + 1900).($t[4] + 1).$t[3].$t[2].$t[1]; |
16
|
0
|
|
|
|
|
|
$$o{output_handler}->($$o{httpHeader}->(-type => 'application/json', -attachment => "$title.json").'['); |
17
|
0
|
|
|
|
|
|
my @selCols = @{ $o->get_usersel_cols() }; |
|
0
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $encoder = JSON::XS->new->utf8(); |
19
|
0
|
|
|
|
|
|
while(my $rec = $o->fetch()) { |
20
|
0
|
|
|
|
|
|
$$o{output_handler}->($encoder->encode($rec)); |
21
|
|
|
|
|
|
|
} |
22
|
0
|
|
|
|
|
|
$$o{output_handler}->(']'); |
23
|
0
|
|
|
|
|
|
$o->finish(); |
24
|
0
|
|
|
|
|
|
return undef; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |