8000 Update JsonResponse.php by esgy · Pull Request #8420 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Update JsonResponse.php #8420

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

Closed
wants to merge 1 commit into from
Closed

Update JsonResponse.php #8420

wants to merge 1 commit into from

Conversation

esgy
Copy link
Contributor
@esgy esgy commented Jul 4, 2013

Added JSON_NUMERIC_CHECK flag to fix issues when json response is used in JavaScript apps and especially in AngularJS.

Added JSON_NUMERIC_CHECK flag to fix issues when json response is used in JavaScript apps and especially in AngularJS.
@fabpot
Copy link
Member
fabpot commented Jul 4, 2013

JSON_NUMERIC_CHECK has been available since PHP 5.3.3, so looks good to me.

@stloyd
Copy link
Contributor
stloyd commented Jul 4, 2013

Shouldn't this be backported to 2.2 ?

fabpot added a commit that referenced this pull request Jul 8, 2013
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #8420).

Discussion
----------

Update JsonResponse.php

Added JSON_NUMERIC_CHECK flag to fix issues when json response is used in JavaScript apps and especially in AngularJS.

Commits
-------

2b1c973 Update JsonResponse.php
@fabpot fabpot closed this Jul 8, 2013
@svperfecta
Copy link

Hi Folks - I think this should be reverted. Per the docs:

'+33123456789'), JSON_NUMERIC_CHECK); ?>

And then you get this JSON:

{"phone_number":33123456789}

This is incorrect. In addition, a string that happens to be a number with leading zeros (ie: 0012) is converted to a string. This broke our app in several unexpected places. We shouldn't be forcing string to integer conversion, if angular wants that behavior I'd consider it custom.

@passion4code
Copy link

Greetings,

I'd like to +1 genexp's comment. An example of why "0012" would be a legit integer is in base16 world. Additionally, some strings could be entirely numeric but need to be treated as a string (such as a person who decided they wanted their username to be a phone number)

@lyrixx
Copy link
Member
lyrixx commented Jul 11, 2013

@esgy This PR was reverted by d3f16d0 ; see #8477

@esgy esgy deleted the patch-1 branch July 23, 2013 13:36
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.

6 participants
0