note 108427 added to function.json-decode
| From: | jakemayer dot at at gmail dot com | Date: | Wed, 25 Apr 2012 19:02:42 +0000 |
| Subject: | note 108427 added to function.json-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187342@lists.php.net to get a copy of this message | ||
Concerning aeternuslibertas at gmail dot com's message:
Well, actually it's not safe to check for
<?php json_decode($input_json) == NULL ?>
since the JSON string can actually be null, but one can use this snippet
<?php
json_decode($input_json);
if(json_last_error()==JSON_ERROR_SYNTAX) {
// error Handling
}
?>
This seems to be the more safe way as it uses the builtin JSON functions to check if a syntax error
has occured during decoding the value in question.
----
Server IP: 69.147.83.197
Probable Submitter: 213.174.243.130
----
Manual Page -- http://www.php.net/manual/en/function.json-decode.php
Edit -- https://master.php.net/note/edit/108427
Del: integrated -- https://master.php.net/note/delete/108427/integrated
Del: useless -- https://master.php.net/note/delete/108427/useless
Del: bad code -- https://master.php.net/note/delete/108427/bad+code
Del: spam -- https://master.php.net/note/delete/108427/spam
Del: non-english -- https://master.php.net/note/delete/108427/non-english
Del: in docs -- https://master.php.net/note/delete/108427/in+docs
Del: other reasons-- https://master.php.net/note/delete/108427
Reject -- https://master.php.net/note/reject/108427
Search -- https://master.php.net/manage/user-notes.php