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

runtime exception when responding with json fails to encode #1684

merged 4 commits into from Jan 1, 2016


None yet
3 participants

zzgab commented Dec 17, 2015

Sometimes you need to respond ->withJson($data) where $data is obtained from a source (database for example) containing characters that he PHP json lib fails to encode.

For example, the é symbol is very basic in French (liberté, égalité, fraternité ;) ), and legacy data sources may contain this letter in the form of chr(233) character code. (This is not the case if the data source is utf8-encoded of course).

json_encode silently fails when the $data contains this char code (as well as many other diacritics). The result is an empty string in the Response body.

I thought that it is important to raise an exception when this occurs.

zzgab added some commits Dec 17, 2015

@akrabat akrabat modified the milestones: 3.2, 3.1.0 Dec 22, 2015

@akrabat akrabat merged commit 950069a into slimphp:3.x Jan 1, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
coverage/coveralls Coverage increased (+1.5%) to 91.145%

akrabat added a commit that referenced this pull request Jan 1, 2016


This comment has been minimized.

Show comment
Hide comment

zzgab Jan 1, 2016




zzgab commented Jan 1, 2016


@akrabat akrabat added the improvement label Jan 1, 2016

rivetchip pushed a commit to rivetchip/Slim that referenced this pull request Jan 22, 2017

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