support JSON version 1 and 2 for Red Hat EL and Debian compatibilities
This commit is contained in:
parent
bc21f58b46
commit
19256b0aaa
|
@ -372,12 +372,22 @@ sub fileUpload {
|
|||
$content =~ s!<!<!g;
|
||||
$content =~ s!>!>!g;
|
||||
|
||||
# Red Hat / Debian compatibilities
|
||||
my $json = new JSON();
|
||||
$json = $json->allow_nonref( ['1'] );
|
||||
$json = $json->utf8( ['1'] );
|
||||
my $json_content = $json->encode($content);
|
||||
my $content = '{"status":"OK", "content":' . $json_content . '}';
|
||||
my $json_content = '';
|
||||
if ($JSON::VERSION lt 2) {
|
||||
local $JSON::UTF8 = 1;
|
||||
$json_content = $json->objToJson([$content]);
|
||||
$json_content =~ s/^\[//;
|
||||
$json_content =~ s/\]$//;
|
||||
}
|
||||
else {
|
||||
$json = $json->allow_nonref( ['1'] );
|
||||
$json = $json->utf8( ['1'] );
|
||||
$json_content = $json->encode($content);
|
||||
}
|
||||
|
||||
my $content = '{"status":"OK", "content":' . $json_content . '}';
|
||||
print $self->header(
|
||||
-type => 'text/html; charset=utf-8',
|
||||
-Content_Length => length $content
|
||||
|
@ -407,12 +417,22 @@ sub urlUpload {
|
|||
$content =~ s!>!>!g;
|
||||
|
||||
# Build JSON reponse
|
||||
# Require Red Hat and Debian compatibilites
|
||||
my $json = new JSON();
|
||||
$json = $json->allow_nonref( ['1'] );
|
||||
$json = $json->utf8( ['1'] );
|
||||
my $json_content = $json->encode($content);
|
||||
$content = '{"status":"OK", "content":' . $json_content . '}';
|
||||
my $json_content = '';
|
||||
if ($JSON::VERSION lt 2) {
|
||||
local $JSON::UTF8 = 1;
|
||||
$json_content = $json->objToJson([$content]);
|
||||
$json_content =~ s/^\[//;
|
||||
$json_content =~ s/\]$//;
|
||||
}
|
||||
else {
|
||||
$json = $json->allow_nonref( ['1'] );
|
||||
$json = $json->utf8( ['1'] );
|
||||
$json_content = $json->encode($content);
|
||||
}
|
||||
|
||||
$content = '{"status":"OK", "content":' . $json_content . '}';
|
||||
print $self->header(
|
||||
-type => 'text/html; charset=utf-8',
|
||||
-Content_Length => length $content
|
||||
|
|
Loading…
Reference in New Issue
Block a user