Edit report at https://bugs.php.net/bug.php?id=69763&edit=1
ID: 69763 User updated by: bruno at skvorc dot me Reported by: bruno at skvorc dot me Summary: Json-c is *not* a drop-in replacement -Status: Closed +Status: Assigned 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 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. Previous Comments: ------------------------------------------------------------------------ [2015-06-07 17:35:57] [email protected] 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] [email protected] 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 -- PECL development discussion Mailing List (http://pecl.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
