steein / json_data
该库是一个面向对象的接口,用于处理JSON格式的数据
dev-master / 1.0.1.x-dev
2017-01-22 00:42 UTC
Requires
- php: ^7.0
- justinrainbow/json-schema: 4.1.0
- phpunit/phpunit: 5.7.5
This package is not auto-updated.
Last update: 2024-09-28 20:25:25 UTC
README
该库是一个面向对象的接口,用于处理JSON格式的数据
用法
示例 1
use SteeinJSON\JSON; $myJson = " { "steein": { "item":"value" } } "; $object = new JSON($myJson);
示例 2
use SteeinJSON\JSON; $object = new JSON(); $object->text->item = 'value'; $object->text->item->one = 'value2'; //By default, simply output through "echo" echo $object; //At the request is allowed to maintain in a JSON file $file = __DIR__.'/json/item.json'; $object->save($file);
与现有对象协同工作
如果您想处理一个现有对象,而不是解析字符串,请将此对象作为构造函数的第三个参数传递
use SteeinJSON\JSON; $object = new JSON(null, null, $customJSON); ///Validating Against a Schema $object->check($customSchema, [$extraSchemaURI => $extraSchemaData]);