jdwx/json-php
最新稳定版本:v1.1.2
Composer 安装命令:
composer require jdwx/json-php
包简介
JSON helper functions for PHP.
README 文档
README
JSON helper functions for PHP.
Installation
You can require it directly with Composer:
composer require jdwx/json-php
Or download the source from GitHub: https://github.com/jdwx/json-php.git
Requirements
This module requires PHP 8.3 or later and the JSON extension.
Usage
Here is a basic usage example:
use JDWX\Json\Json; $data = Json::decode( '{"a":1,"b":2}' ); var_dump( $data ); $json = Json::encode( $data ); echo $json, "\n"; $json = Json::encodePretty( $data ); echo $json, "\n";
This module also supports streaming JSON decoding, such as reading from a JsonLines file:
use JDWX\Json\JsonLines; $stream = fopen( 'file.jsonl', 'r' ); while( $data = JsonLines::decodeFile( $stream ) ) { var_dump( $data ); }
This module also includes:
- lower-level interfaces for streaming JSON decoding that allow (among other things) reading the elements of a JSON list individually without loading the whole list into memory
- a feature-complete JSON lexer that breaks input into discrete JSON elements
Most of the streaming functionality is designed to support cases where JSON input might be problematically large or when it is coming from a potentially endless source, such as a network connection.
There is extensive test coverage for this module, which provides additional examples of usage.
Stability
This module is considered stable and is extensively used in production code.
History
This module was refactored out of a larger codebase in November 2024.
统计信息
- 总下载量: 3.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-19