Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode failure detection is incorrect in PestJSON #53

Merged
merged 2 commits into from
May 9, 2014
Merged

Decode failure detection is incorrect in PestJSON #53

merged 2 commits into from
May 9, 2014

Conversation

arokettu
Copy link
Contributor

@arokettu arokettu commented May 7, 2014

  • json_decode returns NULL not FALSE on decode failure
  • NULL and FALSE are also returned for their valid json counterparts so we also need to check for errors (this also makes failure detection in php < 5.3 a challenge)
json_decode('null') // => null
json_decode('false') // => false

@arokettu
Copy link
Contributor Author

arokettu commented May 7, 2014

For PHP 5.2 we can check by

strtolower(trim($body)) !== 'null'

but I don't think it's a hack suitable for a library

djsipe added a commit that referenced this pull request May 9, 2014
Decode failure detection is incorrect in PestJSON
@djsipe djsipe merged commit 6a8e9f4 into educoder:master May 9, 2014
@djsipe
Copy link
Contributor

djsipe commented May 9, 2014

Good find. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants