Edit JSON Extension


Usage

use php\io\Stream;
use php\format\JsonProcessor;

// Create json processor.
$processor = new JsonProcessor(JsonProcessor::DESERIALIZE_AS_ARRAYS | JsonProcessor::SERIALIZE_PRETTY_PRINT);

// Parse json string, like json_decode().
$point = $processor->parse('{"x": 100, "y": 200}');

// Format to json string, like json_encode().
echo $processor->format($point);

// Also, you can format to php\io\Stream
$processor->formatTo($point, Stream::of('path/to/file.json', 'w+'));

If you want to use the classic php way, you should include jphp-zend extension.