Bug #69763 [Asn->Csd]: Json-c is *not* a drop-in replacement

From: Date: Mon, 08 Jun 2015 14:57:47 +0000
Subject: Bug #69763 [Asn->Csd]: Json-c is *not* a drop-in replacement
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-12997@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69763&edit=1 ID: 69763 Updated by: cmb@php.net Reported by: bruno at skvorc dot me Summary: Json-c is *not* a drop-in replacement -Status: Assigned +Status: Closed Type: Bug Package: PECL Operating System: All PHP Version: 5.6.9 Assigned To: remi Block user comment: N Private report: N New Comment: I don't agree that this is a problem of the JSON documentation in the PHP manual, because it documents the ext/json extension, and not other alternative implementations (one can even think of JSON replacements written in userland). Of course, it seems to be reasonable that alternative implementations point out differences. However, that is already done in README.md of the pecl-json-c[1]: | json_decode use the json-c library and is mostly compatible. | | * > 64 bits integer are always parsed as integer (never float or | string) Please file bugs related to json-c (including its PECL page) to <https://github.com/remicollet/pecl-json-c/issues>, as requested by the package maintainer. [1] <https://github.com/remicollet/pecl-json-c/blob/master/README.md> Previous Comments: ------------------------------------------------------------------------ [2015-06-07 18:59:34] bruno at skvorc dot me I would suggest this remain open because it is as much a bug in jsonc as it is a bug of the PHP docs - example 5 MUST be rectified. ------------------------------------------------------------------------ [2015-06-07 17:35:57] remi@php.net jsonc bug are manage on https://github.com/remicollet/pecl-json-c/issues ------------------------------------------------------------------------ [2015-06-06 11:30:09] bruno at skvorc dot me Fair, but until it is, this disparity should be noted in the PHP docs and using it as a drop-in replacement should be discouraged because there is no feature-for-feature parity. It just doesn't work as documented, simple as that. ------------------------------------------------------------------------ [2015-06-06 11:19:15] cmb@php.net Actually, the package should be "jsonc", but unfortunately that is not available from the list, so I've changed to "PECL". Anyhow, it seems that JSON_BIGINT_AS_STRING is not (yet) fully implemented: <https://github.com/remicollet/pecl-json-c/commit/5822493892c65219db07378f22bb3b1ccb5fdd06>. ------------------------------------------------------------------------ [2015-06-06 09:51:15] bruno at skvorc dot me Description: ------------ --- From manual page: http://www.php.net/function.json-decode --- In example #5, BIGINT is converted to string using the JSON_BIGINT_AS_STRING flag. However, when using Remi's pecl extension (the drop in replacement), this will fail and report an integer overflow notice for numbers larger than signed max integer (like the one in the json_decode documents). Obviously, this is an edge case, but it still *can* and *does* affect some implementations - the API of the company I'm building a lib for sometimes returns unsigned 64bit integers, and thus this will break. Since we're dealing with JSON, the notice headers will break things and make my app unusable unless I use the silence operator(@). More details here: http://stackoverflow.com/questions/30680565/json-decode-and-php-json-bigint-as-string-disparity Test script: --------------- <?php var_dump(json_decode('{"number": 12345678901234567890}', false, 512, JSON_BIGINT_AS_STRING)); Expected result: ---------------- object(stdClass)#1 (1) { ["number"]=> string(20) "12345678901234567890" } Actual result: -------------- https://www.dropbox.com/s/dqquq13pjymeyrt/Screenshot%202015-06-06%2011.48.33.png?dl=0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69763&edit=1

« previous php.pecl.dev (#12997) next »