Ask a Question
Advertise on boostr.in
Organizational Research By
Surprising Reserch Topic
detecting json decode failure in php using -'php,json'
detecting json decode failure in php ¬†using -'php,json'
When using PHP's json_decode(), I don't see a way to distinguish between a NULL return value indicating a failure in decoding and a correctly decoded NULL value:
var_dump(json_decode('nonsense')); // returns NULL
var_dump(json_decode(json_encode(NULL))); // also returns NULL
And case one doesn't throw an exception. So I'm not sure how to test for a decode failure.
Sep 7, 2015
to add a comment.
Related Hot Questions
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
To avoid this verification in future, please