Req #68456 [Com]: json_decode should be able to treat all numbers as strings

From: Date: Tue, 23 Jun 2015 08:19:13 +0000
Subject: Req #68456 [Com]: json_decode should be able to treat all numbers as strings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193781@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68456&edit=1

 ID:                 68456
 Comment by:         admin at bittylicious dot com
 Reported by:        admin at bittylicious dot com
 Summary:            json_decode should be able to treat all numbers as
                     strings
 Status:             Wont fix
 Type:               Feature/Change Request
 Package:            JSON related
 Operating System:   Linux Wheezy
 PHP Version:        5.4.35
 Assigned To:        bukka
 Block user comment: N
 Private report:     N

 New Comment:

OK, thank you for taking this as far as you at all were able to do so.

I still disagree with the outcome (as you may imagine) as this is a feature request that borders on
a bug, but the elders have spoken.

Thanks again.


Previous Comments:
------------------------------------------------------------------------
[2015-06-21 13:36:21] bukka@php.net

The RFC has been rejected and there won't be any json_decode flag that would decode all numbers
as strings.

https://wiki.php.net/rfc/json_numeric_as_string#voting

The more generic solution (e.g. JsonSchema based) is preferred.

------------------------------------------------------------------------
[2015-04-22 18:07:53] admin at bittylicious dot com

Thanks very much for that. I certainly think the severity warrants it considering there is no real
workaround.

------------------------------------------------------------------------
[2015-04-22 17:26:17] bukka@php.net

As I said I don't think that adding new flags is the best solution but it's also true that
properly implementing json schema will take much longer and it's a relatively big feature.

Ok then I will let the PHP members decide. It means that I will proceed with the RFC. I will need to
add more info into it but will probably put it  under discussion in the next few weeks.

------------------------------------------------------------------------
[2015-04-19 22:12:43] yohgaki@php.net

Related bug

https://bugs.php.net/bug.php?id=69422

------------------------------------------------------------------------
[2015-04-19 19:32:17] admin at bittylicious dot com

Thanks for discussing this on the mailing list - good to hear there are some positive comments too.

I still think this, simpler version should be implemented. We already have JSON_BIGINT_AS_STRING so
it seems as though it could be argued as plugging a missing option rather than a full on enhancement
as such. Going the whole hog and allowing object hints etc., is far larger than this; having this
fix go in means that users can implement "casting" to objects manually, but I have no even
remotely-nice workaround I can use to handle these float values at all at present.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=68456


--
Edit this bug report at https://bugs.php.net/bug.php?id=68456&edit=1


Thread (16 messages)

« previous php.bugs (#193781) next »