Commit Graph

80 Commits

Author SHA1 Message Date
Adam Harvey
2d1694d4eb Alter php_json_decode_ex() to respect JSON_BIGINT_AS_STRING for bare numbers.
Fixes bug #63737 (json_decode does not properly decode with options parameter).
2012-12-11 19:51:30 +08:00
Nikita Popov
b7903f9778 Revert JSON merges to 5.4
This reverts the following merge commits (-m 1):

405ebfcd18
d372b33c9b
36fa17a5fa
2012-07-01 16:38:26 +02:00
Nikita Popov
405ebfcd18 Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3:
  Add json_last_error_msg() function
2012-06-28 20:18:19 +02:00
Nikita Popov
974324676b Add json_last_error_msg() function
This replaces json_last_error(true) and is consistent with other custom
error handling functions.
2012-06-28 20:11:27 +02:00
Nikita Popov
d372b33c9b Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3:
  Improve JSON error handling

Conflicts:
	ext/json/tests/bug54058.phpt
	ext/json/tests/bug61537.phpt
2012-06-27 12:28:55 +02:00
Nikita Popov
4662151ea7 Improve JSON error handling
json_encode() no longer throws warnings. Instead only the error code for
json_last_error() is set.

As it is hard to debug the error from just an error code an optional
$as_string parameter was added to json_last_error(), which returns an
error message instead of an error code.
2012-06-27 12:21:48 +02:00
Nikita Popov
36fa17a5fa Merge branch 'PHP-5.3' into PHP-5.4
* PHP-5.3:
  Improve json_encode error handling
  - BFN

Conflicts:
	ext/json/json.c
2012-06-23 21:14:45 +02:00
Nikita Popov
84fe2cc890 Improve json_encode error handling
json_encode() now returns bool(false) for all possible errors, throws the
respective warning and also sets the respective json_last_error() error
code. Three new error codes have been added:

  * JSON_ERROR_RECURSION
  * JSON_ERROR_INF_OR_NAN
  * JSON_ERROR_UNSUPPORTED_TYPE

To get a partial JSON output instead of bool(false) the option
JSON_PARTIAL_OUTPUT_ON_ERROR can be specified. In this case the invalid
segments will be replaced either by null (for recursion, unsupported type
and invalid JSON) or 0 (for Inf and NaN).

The warning for invalid UTF-8 stays intact and is thrown also with
display_errors = On. If this behavior is undesired this can be remedied
later.
2012-06-23 20:51:52 +02:00
Stanislav Malyshev
d84fa39667 Revert "Update test to fix breakage caused by the previous commit."
This reverts commit 05c8d4766c.
Connected to revert 7bbd5521d2.
2012-05-15 23:25:06 -07:00
Felipe Pena
92bc49b2b0 - Fixed bug #61978 (Object recursion not detected for classes that implement JsonSerializable) 2012-05-08 21:05:51 -03:00
Stanislav Malyshev
7bbd5521d2 Revert "Fix bug #61537 (json_encode() incorrectly truncates/discards information) and"
This reverts commit cb2a1c71c9.
The fix is not correct, not fixed after discussion on github.
Please fix the issues and reapply the patch
2012-05-01 23:54:10 -07:00
Adam Harvey
05c8d4766c Update test to fix breakage caused by the previous commit. 2012-04-11 08:29:39 +08:00
Adam Harvey
cb2a1c71c9 Fix bug #61537 (json_encode() incorrectly truncates/discards information) and
remove a test case that's now mooted by this fix.
2012-04-11 08:29:39 +08:00
Adam Harvey
3f3ad30c50 Fix bug #61537 (json_encode() incorrectly truncates/discards information) and
remove a test case that's now mooted by this fix.
2012-04-11 08:24:38 +08:00
Ilia Alshanetsky
199b52c1d4 Fixed bug #55543 (json_encode() with JSON_NUMERIC_CHECK fails on objects with numeric string properties) 2011-10-17 23:51:25 +00:00
Ilia Alshanetsky
d4ae4e79db Fixed bug #55543 (json_encode() with JSON_NUMERIC_CHECK fails on objects with numeric string properties) 2011-10-17 23:51:25 +00:00
Gwynne Raskind
81ee8a6c7b Add test for #53946 to 5.4 (missed it when committing revision 315707) 2011-08-29 14:57:53 +00:00
Christopher Jones
52cc62d825 Remove duplicate lines present in PHP_5_3's .phpt (dtajchreber) 2011-06-17 21:42:40 +00:00
Ilia Alshanetsky
f4f2aa7583 Fixed bug #54484 (Empty string in json_decode doesn't reset json_last_error()). 2011-06-01 09:44:38 +00:00
Ilia Alshanetsky
a7dfb31557 Fixed bug #54484 (Empty string in json_decode doesn't reset json_last_error()). 2011-06-01 09:44:38 +00:00
Scott MacVicar
ecb9d8019c Fix Bug #54058, invalid utf-8 doesn't set json_encode() in all cases 2011-02-21 08:09:02 +00:00
Scott MacVicar
3242016f28 Fix Bug #54058, invalid utf-8 doesn't set json_encode() in all cases 2011-02-21 08:09:02 +00:00
Adam Harvey
cb9c8233fc Implement FR #44331 (Formatting option for json_encode). Bikeshedding about the
exact form of the JSON pretty printing and brace handling will only be accepted
in the form of patches. ;)
2010-09-16 16:21:15 +00:00
Adam Harvey
726fe638bb Implemented FR #49366 (Make slash escaping optional in json_encode()). 2010-09-16 13:53:27 +00:00
Sara Golemon
6eb4218433 Add JSON_BIGINT_AS_STRING for json_decode() to parse large numbers
as strings rather than casting to double and loosing precision.
2010-05-21 22:59:58 +00:00
Ilia Alshanetsky
ea3a6539dc Added support for JSON_NUMERIC_CHECK option in json_encode() that converts
numeric strings to integers.
2010-05-20 19:37:52 +00:00
Ilia Alshanetsky
cf174c1366 Added support for JSON_NUMERIC_CHECK option in json_encode() that converts
numeric strings to integers.
2010-05-20 19:37:52 +00:00
Sara Golemon
1fd85e29de Rename JSON_Serializable to JsonSerializable per ML discussion 2010-05-12 16:42:48 +00:00
Sara Golemon
1381b14eaa Add JSON_Serializable interface
Objects implementing JSON_Serializable will have
their ->jsonSerialize() method called

Similar to serialize() and __sleep()
2010-05-05 22:48:14 +00:00
Felipe Pena
a90c801c2f - Fixed tests 2010-04-03 15:42:42 +00:00
Felipe Pena
4d571dee74 - Fixed tests 2010-04-03 15:42:42 +00:00
Rasmus Lerdorf
8af64e6f34 Fix broken json tests in all branches 2009-08-03 04:01:57 +00:00
Alexey Zakhlestin
3e326b91e7 fix tests corrupted by svn's eol-style=native 2009-07-15 13:44:14 +00:00
andy wharmby
a6735b8b24 New json extension tests. Tested on Windows, Linux and Linux 64 bit. 2009-06-14 12:08:27 +00:00
Scott MacVicar
a23b4073e8 MFH Missing skip in tests 2009-03-17 23:31:14 +00:00
Scott MacVicar
8d2a5cabec MFH Add PHP_JSON_FORCE_OBJECT for forcing an object output of an array 2009-03-17 23:15:40 +00:00
Scott MacVicar
07e675cc52 MFH Fix bug #47644 - Valid integers are truncated with json_decode() 2009-03-17 02:00:13 +00:00
andy wharmby
b2f1d92674 Fix tests. Add missing SKIPIF. Tested on Windows, Linux and Linux 64 2009-01-23 20:23:29 +00:00
Scott MacVicar
6fe58b3542 Fix test again... 2009-01-08 14:09:49 +00:00
Scott MacVicar
b08ceb79b3 Fix broken test 2009-01-08 13:35:58 +00:00
Scott MacVicar
0bdbc4e356 MFH Fix bug #46944 - UTF-8 characters outside the BMP aren't encoded correctly. 2009-01-02 03:02:22 +00:00
Scott MacVicar
fdf2d1e46f MFH Add json_last_error() for getting a bit of information about what failed during a decode, also fixes a segfault when we have [1}
[DOC]
2008-12-19 02:00:57 +00:00
Scott MacVicar
e5587ee4cc MFH Test for bug #45791 2008-12-17 14:46:47 +00:00
Scott MacVicar
ed5f04710b MFH Fix bug #45989 - json_decode() doesn't return NULL on certain invalid strings 2008-12-12 23:19:47 +00:00
Felipe Pena
83c0eb69ad - Fixed tests 2008-11-19 16:58:28 +00:00
Felipe Pena
3ecc545018 - New test 2008-10-02 03:36:52 +00:00
Rasmus Lerdorf
c6671a0596 Fix test to test higher nesting level 2008-07-31 11:46:23 +00:00
Antony Dovgal
0c01626f1c MFH 2008-02-15 09:20:25 +00:00
Stanislav Malyshev
b4443f35ff fix #43941: invalid utf-8 not accepted 2008-01-30 03:17:57 +00:00
Dmitry Stogov
ebf4cd30db Fixed test related to bug #38469 2007-12-28 13:23:00 +00:00