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

Return null on empty json string in PHP7 #712

Open
wants to merge 1 commit into
base: working
Choose a base branch
from

Conversation

thomaslorentsen
Copy link

PHP7 no longer considers an empty string as valid JSON.

When passing an empty string to json_decode an exception is raised instead of returning null.

This is documented on the PHP7 Backward incompatible changes page.

I have updated the method to check for an empty response string and return null instead.

PHP7 uses the JSOND extension for parsing JSON which now throws an error
on an empty string. The JSON response is checked whether it is empty
before decoding it and returns null for backwards compatibility.
@thomaslorentsen thomaslorentsen changed the title Fix return null on empty json string in PHP7 Return null on empty json string in PHP7 Aug 26, 2017
@coveralls
Copy link

coveralls commented Aug 26, 2017

Coverage Status

Coverage increased (+0.006%) to 88.777% when pulling 07a84ab on thomaslorentsen:working into ea17eff on rackspace:working.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.006%) to 88.777% when pulling 07a84ab on thomaslorentsen:working into ea17eff on rackspace:working.

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.

None yet

2 participants