output error if json_encode fails

This commit is contained in:
hannes 2016-01-23 15:01:27 +00:00
parent 81f9a59f25
commit 4e50717e12

View File

@ -771,9 +771,15 @@ class ApiAction extends Action
function showJsonObjects($objects)
{
print(json_encode($objects));
$json_objects = json_encode($objects);
if($json_objects === false) {
$this->clientError(_('JSON encoding failed. Error: ').json_last_error_msg());
} else {
print $json_objects;
}
}
function showSingleXmlStatus($notice)
{
$this->initDocument('xml');
@ -1558,4 +1564,4 @@ class ApiAction extends Action
return $uri;
}
}
}