This commit is contained in:
jorgecc
2022-11-07 11:42:04 -03:00
parent 7094ebc3f1
commit 82c2cad5f9
2 changed files with 50 additions and 13 deletions
+16
View File
@@ -4,9 +4,25 @@ use eftec\ServicesJson\Services_JSON;
include '../vendor/autoload.php';
// $json_decoder = new Services_JSON(SERVICES_JSON_IN_ARR | SERVICES_JSON_LOOSE_TYPE)
$s=new Services_JSON();
$json='{hello:{a:2,b:3},world:[1,2,3,"aaa","bbbb"]}';
var_dump(my_json_decode($json));
function my_json_decode($s) {
$s = str_replace(
array('"', "'"),
array('\"', '"'),
$s
);
$s = preg_replace('/(\w+):/i', '"\1":', $s);
return json_decode(sprintf('{%s}', $s));
}
echo "Decode as stdclass:<br>";
echo "<pre>";
var_dump($s->decode($json));