cortexphp/json-repair
Composer 安装命令:
composer require cortexphp/json-repair
包简介
Repair invalid JSON strings by fixing common syntax errors like single quotes, unquoted keys, trailing commas, and missing brackets. Perfect for parsing LLM outputs and malformed API responses.
README 文档
README
Repair invalid JSON strings by automatically fixing common syntax errors like single quotes, unquoted keys, trailing commas, and missing brackets.
Requirements
- PHP 8.3+
- JSON PHP extension
Installation
composer require cortexphp/json-repair
Quick Start
use Cortex\JsonRepair\JsonRepairer; use function Cortex\JsonRepair\json_repair; use function Cortex\JsonRepair\json_repair_decode; // Broken JSON (single quotes, unquoted keys, trailing comma) $broken = "{'name': 'John', age: 30, active: true,}"; $repaired = (new JsonRepairer($broken))->repair(); // {"name": "John", "age": 30, "active": true} // Or use the helper function $repaired = json_repair($broken); // Repair and decode in one step $data = (new JsonRepairer($broken))->decode(); // ['name' => 'John', 'age' => 30, 'active' => true] // Or use the helper function $data = json_repair_decode($broken);
Documentation
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 4.98k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-25