1BnWr4haCmIoRsscY9fpWt changeset

Changesetdf595a9fb894 (b)
ParentNone (a)
ab
0+--TEST--
0+json_decode() function - a test to verify that json_decode() returns NULL on an invalid json string
0+--SKIPIF--
0+<?php if (!function_exists('json')) echo "SKIP"; ?>
0+--FILE--
0+<?php
0+/**
0+ * All values were verified to be invalid JSON on jsonlint.com.
0+ *
0+ * Therefor, json_encode() should return NULL on those values as noted in the documentation.
0+ *
0+ * @link http://bugs.php.net/bug.php?id=45989
0+ */
0+var_dump(json_decode("'invalid json'"));
0+var_dump(json_decode('invalid json'));
0+var_dump(json_decode(' {'));
0+var_dump(json_decode(' ['));
0+?>
0+--EXPECT--
0+NULL
0+NULL
0+NULL
0+NULL
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--- Revision None
+++ Revision df595a9fb894
@@ -0,0 +1,23 @@
+--TEST--
+json_decode() function - a test to verify that json_decode() returns NULL on an invalid json string
+--SKIPIF--
+<?php if (!function_exists('json')) echo "SKIP"; ?>
+--FILE--
+<?php
+/**
+ * All values were verified to be invalid JSON on jsonlint.com.
+ *
+ * Therefor, json_encode() should return NULL on those values as noted in the documentation.
+ *
+ * @link http://bugs.php.net/bug.php?id=45989
+ */
+var_dump(json_decode("'invalid json'"));
+var_dump(json_decode('invalid json'));
+var_dump(json_decode(' {'));
+var_dump(json_decode(' ['));
+?>
+--EXPECT--
+NULL
+NULL
+NULL
+NULL