- json_decode: documentation ( source)
- preg_replace_callback: documentation ( source)
- var_export: documentation ( source)
- sprintf: documentation ( source)
<?php
$json = '{"test" : "test one \xe0, \x270B"}';
echo var_export(json_validate($json), true);
$json = preg_replace_callback(
pattern: '/\\\\x([[:xdigit:]]+)/',
callback: fn($m) => sprintf('\u%04s', $m[1]),
subject: $json,
count: $count
);
echo "\n$count";
echo "\n" . var_export(json_validate($json), true);
echo "\n$json\n";
var_export(json_decode($json));