finagin/json

JSON class with throw exception

1.0.3 2021-02-04 12:48 UTC

This package is auto-updated.

Last update: 2024-05-04 21:10:46 UTC


README

Latest Version on Packagist StyleCI Total Downloads 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e7376673f7374796c653d666c61742d737175617265
GitHub stars

Installation

This package can be used with PHP 7.3 or higher. You can install the package via composer:

composer require finagin/json

Usage

use Finagin\Json\Facades\Json;

try {
    // decode as object
    Json::decode($fromJson);
    Json::decodeAsObject($fromJson);
    
    // decode as array
    Json::decode($fromJson, 0, true);
    Json::decodeAsArray($fromJson);
    
    Json::encode($toJson, JSON_PRETTY_PRINT);
} catch (\JsonException $exception) {
    //
}

License

The MIT License (MIT). Please see License File for more information.