Prettify json on manager conf export (#2292)
This commit is contained in:
parent
bcb6c428f1
commit
d5b47115ee
|
@ -769,8 +769,8 @@ sub metadata {
|
||||||
return $self->sendJSONresponse(
|
return $self->sendJSONresponse(
|
||||||
$req,
|
$req,
|
||||||
$self->currentConf,
|
$self->currentConf,
|
||||||
forceJSON => 1,
|
pretty => 1,
|
||||||
headers => [
|
headers => [
|
||||||
'Content-Disposition' => "Attachment; filename=lmConf-$c.json"
|
'Content-Disposition' => "Attachment; filename=lmConf-$c.json"
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
@ -125,7 +125,23 @@ sub sendJSONresponse {
|
||||||
$args{headers} ||= [ $req->spliceHdrs ];
|
$args{headers} ||= [ $req->spliceHdrs ];
|
||||||
my $type = 'application/json; charset=utf-8';
|
my $type = 'application/json; charset=utf-8';
|
||||||
if ( ref $j ) {
|
if ( ref $j ) {
|
||||||
eval { $j = $_json->encode($j); };
|
eval {
|
||||||
|
if ( $args{pretty} ) {
|
||||||
|
|
||||||
|
# This avoids changing the settings of the $_json reference
|
||||||
|
$j = to_json(
|
||||||
|
$j,
|
||||||
|
{
|
||||||
|
allow_nonref => 1,
|
||||||
|
pretty => 1,
|
||||||
|
canonical => 1
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$j = $_json->encode($j);
|
||||||
|
}
|
||||||
|
};
|
||||||
return $self->sendError( $req, $@ ) if ($@);
|
return $self->sendError( $req, $@ ) if ($@);
|
||||||
}
|
}
|
||||||
return [ $args{code}, [ 'Content-Type' => $type, @{ $args{headers} } ],
|
return [ $args{code}, [ 'Content-Type' => $type, @{ $args{headers} } ],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user