digiaonline/json-helpers

This package is abandoned and no longer maintained. No replacement package was suggested.

Exception-based wrappers for json_encode and json_decode

1.0.0 2017-10-08 10:55 UTC

This package is auto-updated.

Last update: 2023-03-12 20:49:41 UTC


README

Build Status

Exception-based wrappers for json_encode and json_decode

Requirements

  • PHP >= 7.0

Installation

composer require digiaonline/json-helpers

Usage

Encoding

<?php

$data = [
    'foo' => 'bar'  
];

try {
    $json = \Digia\JsonHelpers\JsonEncoder::encode($data);    
}
catch (\InvalidArgumentException $e) {
    
}

Decoding

<?php

$json = '["foo":"bar"]';

try {
    $data = \Digia\JsonHelpers\JsonDecoder::decode($data);    
}
catch (\InvalidArgumentException $e) {
    
}

License

MIT