Hacker News new | ask | show | jobs
by mmosta 2938 days ago

  - JSON:
  . Added JSON_THROW_ON_ERROR flag. (Andrea)
A blessed day, prior to this, json_decode would simply return null on error.
1 comments

Absolutely, before you had to do some check like:

if(null === $data = json_decode($json)) throw new Exception();

Wrong! "null" is a valid JSON-serialized value! You MUST call json_last_error.

Better yet - don't use PHP.