--TEST--
Behavior of union type checks (strict)
---SKIPIF--
-<?php
-if (!extension_loaded('json')) die('skip requires json');
-?>
--FILE--
<?php
--TEST--
Behavior of union type checks (weak)
---SKIPIF--
-<?php
-if (!extension_loaded('json')) die('skip requires json');
-?>
--FILE--
<?php
--TEST--
json_decode() tests
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
json_encode() tests
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
json_encode() & endless loop - 1
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
json_encode() & endless loop - 2
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
json_encode() & endless loop - 3
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
json_encode() & extended encoding
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
$a = array('<foo>', "'bar'", '"baz"', '&blong&');
--TEST--
json_last_error() tests
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
var_dump(json_decode("[1]"));
--TEST--
json_decode() with large integers
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
$json = '{"largenum":123456789012345678901234567890}';
--TEST--
json_encode() with non-packed array that should be encoded as an array rather than object
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
$a = array(1, 2, 3, 'foo' => 'bar');
Bug #40503 (json_encode() value corruption on 32bit systems with overflown values)
--INI--
serialize_precision=-1
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
function json_test_show_eq($x, $y) {
--TEST--
Bug #41034 (json_encode() ignores null byte started keys in arrays)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
echo json_encode(array(0, "\0ab"=>1, "\0null-prefixed value"));
--TEST--
Bug #41067 (json_encode() problem with UTF-16 input)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
$single_barline = "\360\235\204\200";
Bug #41403 (json_decode cannot decode floats if localeconv decimal_point is not '.')
--SKIPIF--
<?php
-if (!extension_loaded('json')) die('skip');
if (setlocale(LC_NUMERIC, "de_DE") === false) {
die("skip no de_DE locale");
}
--TEST--
Bug #41504 (json_decode() converts empty array keys to "_empty_")
---SKIPIF--
-<?php if (!extension_loaded('json')) print 'skip'; ?>
--FILE--
<?php
Bug #41567 (json_encode() double conversion is inconsistent with PHP)
--INI--
serialize_precision=-1
---SKIPIF--
-<?php if (!extension_loaded('json')) print 'skip'; ?>
--FILE--
<?php
--TEST--
Bug #42090 (json_decode causes segmentation fault)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
var_dump(
serialize_precision=-1
--SKIPIF--
<?php
-if (!extension_loaded('json')) die('skip');
if (!setlocale(LC_CTYPE, "de_DE", "de", "german", "ge", "de_DE.ISO8859-1", "ISO8859-1")) {
die("skip locale needed for this test is not supported on this platform");
}
--TEST--
Bug #43941 (json_encode() invalid UTF-8)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Bug #45791 (json_decode() does not handle number 0e0)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Bug #46215 (json_encode mutates its parameter and has some class-specific state)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Bug #46944 (json_encode() doesn't handle 3 byte utf8 correctly)
---SKIPIF--
-<?php if (!extension_loaded('json')) print 'skip'; ?>
--FILE--
<?php
Bug #47644 (valid large integers are truncated)
--SKIPIF--
<?php
-if (!extension_loaded('json')) die('skip');
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--FILE--
bug #50224 (json_encode() does not always encode a float as a float)
--INI--
serialize_precision=-1
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
echo "* Testing JSON output\n\n";
--TEST--
bug #53946 (json_encode() with JSON_UNESCAPED_UNICODE)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
var_dump(json_encode("latin 1234 -/ russian мама мыла раму specialchars \x02 \x08 \n U+1D11E >𝄞<"));
--TEST--
Bug #54058 (json_last_error() invalid UTF-8 produces wrong error)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Bug #54484 (Empty string in json_decode doesn't reset json_last_error)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
json_decode('{"test":"test"}');
--TEST--
Bug #55543 (json_encode() with JSON_NUMERIC_CHECK & numeric string properties)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
$a = new stdClass;
--TEST--
Bug #61537 (json_encode() incorrectly truncates/discards information)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
$invalid_utf8 = "\x9f";
--TEST--
Bug #61978 (Object recursion not detected for classes that implement JsonSerializable)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Bug #62010 (json_decode produces invalid byte-sequences)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
FR #62369 (Segfault on json_encode(deeply_nested_array)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Bug #63737 (json_decode does not properly decode with options parameter)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
function decode($json) {
--TEST--
Bug #64695 JSON_NUMERIC_CHECK has issues with strings that are numbers plus the letter e
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
$t = array('test' => '123343e871700');
--TEST--
Whitespace part of bug #64874 ("json_decode handles whitespace and case-sensitivity incorrectly")
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
function decode($json) {
--TEST--
Case-sensitivity part of bug #64874 ("json_decode handles whitespace and case-sensitivity incorrectly")
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
function decode($json) {
--TEST--
Bug #66021 (Blank line inside empty array/object when JSON_PRETTY_PRINT is set)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Bug #66025 (Indent wrong when json_encode() called from jsonSerialize function)
---SKIPIF--
-<?php
-if (!extension_loaded('json')) die('skip');
-?>
--FILE--
<?php
--TEST--
Bug #68546 (json_decode() Fatal error: Cannot access property started with '\0')
---SKIPIF--
-<?php
-
-if (!extension_loaded('json')) die('skip');
-?>
--FILE--
<?php
--TEST--
Bug #68567 JSON_PARTIAL_OUTPUT_ON_ERROR can result in JSON with null key
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Bug #68817 (Null pointer deference)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Bug #68938 (json_decode() decodes empty string without indicating error)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
json_decode("");
--TEST--
Bug #68992 (json_encode stacks exceptions thrown by JsonSerializable classes)
---SKIPIF--
-<?php
-if (!extension_loaded('json')) die('skip');
-?>
--FILE--
<?php
--TEST--
Bug #69187 json_last_error return BC in PHP7
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
var_dump(json_decode(NULL));
--TEST--
Bug #71835 (json_encode sometimes incorrectly detects recursion with JsonSerializable)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
class SomeClass implements JsonSerializable {
--TEST--
Bug #72069 (Behavior \JsonSerializable different from json_encode)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Bug #72787 (json_decode reads out of bounds)
--SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
--FILE--
<?php
--TEST--
Bug #73113 (Segfault with throwing JsonSerializable)
Also test that the custom exception is not wrapped by ext/json
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Bug #73254 (Incorrect indentation generated by json_encode() with JSON_PRETTY_PRINT)
---SKIPIF--
-<?php
-if (!extension_loaded('json')) die('skip');
-?>
--FILE--
<?php
--TEST--
Allow JSON_OBJECT_AS_ARRAY to have an effect
---SKIPIF--
-<?php if(!extension_loaded('json')) die('skip json extension not loaded') ?>
--FILE--
<?php
--TEST--
Bug #77843: Use after free with json serializer
---SKIPIF--
-<?php if(!extension_loaded('json')) die('skip json extension not loaded') ?>
--FILE--
<?php
--TEST--
JSON (http://www.crockford.com/JSON/JSON_checker/test/fail*.json)
---SKIPIF--
-<?php
- if (!extension_loaded('json')) die('skip');
-?>
--FILE--
<?php
--TEST--
An error is thrown when INF or NaN are encoded
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
Test json_decode() function : basic functionality
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
echo "*** Testing json_decode() : basic functionality ***\n";
--TEST--
Test json_decode() function : error conditions
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
echo "*** Testing json_decode() : error conditions ***\n";
--TEST--
Test json_decode() function : JSON_THROW_ON_ERROR flag
---SKIPIF--
-<?php if(!extension_loaded('json')) die('skip json extension not loaded') ?>
--FILE--
<?php
--TEST--
json_decode() invalid UTF8
---SKIPIF--
-<?php
-if (!extension_loaded("json")) print "skip";
-?>
--FILE--
<?php
function json_decode_invalid_utf8($str) {
--TEST--
Test json_encode() function : basic functionality
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
echo "*** Testing json_encode() : basic functionality ***\n";
--TEST--
Test json_encode() function : basic functionality with UTF8 string input
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
echo "*** Testing json_encode() : basic functionality with UTF-8 input***\n";
--TEST--
Test json_encode() function : JSON_THROW_ON_ERROR flag
---SKIPIF--
-<?php if(!extension_loaded('json')) die('skip json extension not loaded') ?>
--FILE--
<?php
--TEST--
json_encode() invalid UTF8
---SKIPIF--
-<?php
-if (!extension_loaded("json")) print "skip";
-?>
--FILE--
<?php
function json_encode_invalid_utf8($str) {
Test json_encode() function with numeric flag
--INI--
serialize_precision=-1
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
var_dump(
--TEST--
json_encode() with JSON_PRETTY_PRINT
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
function encode_decode($json) {
--TEST--
json_encode() tests for U+2028, U+2029
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
var_dump(json_encode(array("a\xC3\xA1b")));
--TEST--
json_decode() tests
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
var_dump(json_encode('a/b'));
--TEST--
JSON_THROW_ON_ERROR: global error flag untouched
---SKIPIF--
-<?php if(!extension_loaded('json')) die('skip json extension not loaded') ?>
--FILE--
<?php
--TEST--
json_last_error() failures
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
json_last_error_msg() failures
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
JSON (http://www.crockford.com/JSON/JSON_checker/test/pass1.json)
--INI--
serialize_precision=-1
---SKIPIF--
-<?php
-if (!extension_loaded('json')) die('skip json extension not loaded');
-?>
--FILE--
<?php
/* Modified to test unescaped UNICODE as keys and values.
,\"rosebud\"]
";
-echo 'Testing: ' . $test . "\n";
+echo 'Testing:' . $test . "\n";
echo "DECODE: AS OBJECT\n";
$obj = json_decode($test);
var_dump($obj);
?>
--EXPECTF--
-Testing:
+Testing:
[
"JSON Test Pattern pass1",
{"object with 1 member":["array with 1 element"]},
serialize_precision=-1
--SKIPIF--
<?php
-if (!extension_loaded('json')) die('skip');
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
?>
--FILE--
,\"rosebud\"]
";
-echo 'Testing: ' . $test . "\n";
+echo 'Testing:' . $test . "\n";
echo "DECODE: AS OBJECT\n";
$obj = json_decode($test);
var_dump($obj);
?>
--EXPECTF--
-Testing:
+Testing:
[
"JSON Test Pattern pass1",
{"object with 1 member":["array with 1 element"]},
JSON (http://www.crockford.com/JSON/JSON_checker/test/pass1.json)
--INI--
serialize_precision=-1
---SKIPIF--
-<?php
-if (!extension_loaded('json')) die('skip');
-?>
--FILE--
<?php
,\"rosebud\"]
";
-echo 'Testing: ' . $test . "\n";
+echo 'Testing:' . $test . "\n";
echo "DECODE: AS OBJECT\n";
$obj = json_decode($test);
var_dump($obj);
?>
--EXPECT--
-Testing:
+Testing:
[
"JSON Test Pattern pass1",
{"object with 1 member":["array with 1 element"]},
--TEST--
JSON (http://www.crockford.com/JSON/JSON_checker/test/pass2.json)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
JSON (http://www.crockford.com/JSON/JSON_checker/test/pass3.json)
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
}
';
-echo 'Testing: ' . $test . "\n";
+echo 'Testing:' . $test . "\n";
echo "DECODE: AS OBJECT\n";
$obj = json_decode($test);
var_dump($obj);
?>
--EXPECTF--
-Testing:
+Testing:
{
"JSON Test Pattern pass3": {
"The outermost value": "must be an object or array.",
json_encode() Serialization tests
--INI--
serialize_precision=-1
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
--TEST--
An error is thrown when an unsupported type is encoded
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
Edge-cases in constant conditional jump elimination
--SKIPIF--
<?php if (PHP_INT_SIZE != 8) die("skip for machines with 64-bit longs"); ?>
-<?php if (!extension_loaded("json")) print "skip"; ?>
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
--TEST--
Bug #79241: Segmentation fault on preg_match()
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip json extension missing"; ?>
--FILE--
<?php
--SKIPIF--
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
-if (!extension_loaded('json')) die('skip json ext not loaded');
require __DIR__ . '/config.inc';
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
--SKIPIF--
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
-if (!extension_loaded('json')) die('skip json extension not available');
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
require_once dirname(__FILE__) . '/config.inc';
PDOTest::skip();
Bug #66084 simplexml_load_string() mangles empty node name, json variant
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip simplexml not available"; ?>
-<?php if (!extension_loaded("json")) print "skip json not available"; ?>
--FILE--
<?php
echo json_encode(simplexml_load_string('<a><b/><c><x/></c></a>')->c), "\n";
--TEST--
Test is_callable() function : usage variations - undefined functions
---SKIPIF--
-<?php
-if (!extension_loaded('json')) die("skip requires ext/json");
-?>
--FILE--
<?php
/* Prototype: bool is_callable ( mixed $var [, bool $syntax_only [, string &$callable_name]] );
die("skip - locale needed for this test is not supported on this platform");
}
-if (!extension_loaded("json")) {
- print "skip - test requires the json extension";
-}
-
?>
--FILE--
<?php
--TEST--
Test base64_decode() function : basic functionality - padding and whitespace
---SKIPIF--
-<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
/* Prototype : proto string base64_decode(string str[, bool strict])