schnittstabil/json-decode-file

读取和解码 JSON 文件

2.1.0 2018-03-25 14:57 UTC

This package is auto-updated.

Last update: 2024-08-26 02:05:27 UTC


README

SensioLabsInsight

读取和解码 JSON 文件

处理 UTF 字节顺序标记 (BOM),使用 kherge/file-managerseld/jsonlint 分别抛出有用的文件和 JSON 异常。

安装

$ composer require schnittstabil/json-decode-file

用法

use function Schnittstabil\JsonDecodeFile\jsonDecodeFile;

try {
    $json = jsonDecodeFile('composer.json');
} catch (\KHerGe\File\Exception\ResourceException $err) {
    echo $err->getMessage(), PHP_EOL;
} catch (\Seld\JsonLint\ParsingException $err) {
    echo $err->getMessage(), PHP_EOL;
}

相关

许可证

MIT © Michael Mayer