Skip to content

Instantly share code, notes, and snippets.

@thejhh
Created April 10, 2012 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejhh/2353872 to your computer and use it in GitHub Desktop.
Save thejhh/2353872 to your computer and use it in GitHub Desktop.

Funny thing with json_decode...

$ php
<?php echo var_export(json_decode("true ", true), true) ?>
NULL

(Press ctrl-d after you write "?>".)

The same using node.js:

$ node
> JSON.parse("true ")
true
> exit

Of course it could be argued that it's a good feature to not ignore leading white spaces. However most text editors are going to write at least one line break at the end of files -- and that kind of line break was the problem of my bug at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment