note 115926 added to function.json-last-error-msg
| From: | Anonymous | Date: | Wed, 15 Oct 2014 08:37:52 +0000 |
| Subject: | note 115926 added to function.json-last-error-msg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200652@lists.php.net to get a copy of this message | ||
seregynp :
a better way to test JSON
<?php
$json = json_decode('wrong json');
if ($json === null && json_last_error() !== JSON_ERROR_NONE) {
throw new \LogicException(sprintf("Failed to parse json string '%s', error:
'%s'", $json , json_last_error_msg()));
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 213.151.170.194
----
Manual Page -- http://php.net/manual/en/function.json-last-error-msg.php
Edit -- https://master.php.net/note/edit/115926
Del: integrated -- https://master.php.net/note/delete/115926/integrated
Del: useless -- https://master.php.net/note/delete/115926/useless
Del: bad code -- https://master.php.net/note/delete/115926/bad+code
Del: spam -- https://master.php.net/note/delete/115926/spam
Del: non-english -- https://master.php.net/note/delete/115926/non-english
Del: in docs -- https://master.php.net/note/delete/115926/in+docs
Del: other reasons-- https://master.php.net/note/delete/115926
Reject -- https://master.php.net/note/reject/115926
Search -- https://master.php.net/manage/user-notes.php