-
Notifications
You must be signed in to change notification settings - Fork 159
JSON Extension
Dmitriy Zayceff edited this page Apr 24, 2015
·
5 revisions
- Since: 0.6.3
- Dependency:
org.develnext:jphp-json-ext
- API: http://jphp-docs.readthedocs.org/en/latest/api_en/php/format/JsonProcessor/
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.
JPHP Group 2015