Leser: 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
if ($FORM{'type'} eq "db") { my %UDIoutput = (); my $count = 0; for my $line (@DATABASE) { $count++; my ($type,$datestamp,$file,$title) = split(/\e/, $line); $file =~ s/\//,/g; my $PIDurl = $HOSTurl."?PID=".$file; my $JSONurl = $HOSTurl."?PID=".$file."&udi=json&type=pid"; my %entry = ( 'datestamp' => $datestamp, 'pid' => $PIDurl, 'json' => $JSONurl); %UDIoutput = ( $count => \%entry ); } # create and sort the JSON ouput use JSON::PP; my $json_text = JSON::PP->new()->sort_by(sub { $JSON::PP::a cmp $JSON::PP::b })->pretty(1)->encode(\%UDIoutput); print "Content-type: text/html\n\n"; print $json_text; }
1
2
3
4
5
6
7
{
"43" : {
"datestamp" : "201011241811",
"json" : "http://foo.bar/?PID=static,ressort,Internet,test_de&udi=json&type=pid",
"pid" : "http://foo.bar/?PID=static,ressort,Internet,test_de"
}
}
$UDIoutput{$count} = \%entry;