From: hannes Date: Sat, 23 Jan 2016 15:01:27 +0000 (+0000) Subject: output error if json_encode fails X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4e50717e12722bc68b63fc713683392c69f56196;p=quix0rs-gnu-social.git output error if json_encode fails --- diff --git a/lib/apiaction.php b/lib/apiaction.php index 8420bfb51e..24f42e4a41 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -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; } -} +} \ No newline at end of file