Prettify json on manager conf export (#2292)
This commit is contained in:
parent
bcb6c428f1
commit
d5b47115ee
|
@ -769,7 +769,7 @@ sub metadata {
|
|||
return $self->sendJSONresponse(
|
||||
$req,
|
||||
$self->currentConf,
|
||||
forceJSON => 1,
|
||||
pretty => 1,
|
||||
headers => [
|
||||
'Content-Disposition' => "Attachment; filename=lmConf-$c.json"
|
||||
],
|
||||
|
|
|
@ -125,7 +125,23 @@ sub sendJSONresponse {
|
|||
$args{headers} ||= [ $req->spliceHdrs ];
|
||||
my $type = 'application/json; charset=utf-8';
|
||||
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 [ $args{code}, [ 'Content-Type' => $type, @{ $args{headers} } ],
|
||||
|
|
Loading…
Reference in New Issue
Block a user