schnittstabil/json-decode-file

Read and decode JSON files

2.1.0 2018-03-25 14:57 UTC

This package is auto-updated.

Last update: 2024-10-26 02:29:53 UTC


README

SensioLabsInsight

Read and decode JSON files

Handles UTF byte order marks (BOM), uses kherge/file-manager and seld/jsonlint to throw helpful File and JSON Exceptions respectively.

Install

$ composer require schnittstabil/json-decode-file

Usage

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;
}

Related

  • load-json-file – Node.js version and inspiration of this projeject

License

MIT © Michael Mayer