johnykvsky/jsonhelper

JsonHelper for easier Json handling

0.0.2 2019-05-22 19:02 UTC

This package is auto-updated.

Last update: 2022-11-15 11:30:28 UTC


README

Latest Version on Packagist Software License Total Downloads

JsonHelper - for easy JSON handling

Install

Via Composer

$ composer require johnykvsky/jsonhelper

Should work fine on PHP 5.6, but I didn't check that. Just change required PHP version in composer.json and maybe remove dev packages.

Features

  • Proper error handling on encode/decode
  • By default decode to array
  • Nice isValidJson() for checking
  • convertNewLinesToCRLF() for arrays/strings, fix for some wierd newlines types witch makes encode() fail

Usage

use johnykvsky\Utils\JsonHelper;

JsonHelper::encode(array('works' => 'fine'));
JsonHelper::decode('{"works:"fine"}');
JsonHelper::isValidJson('{"works:"fine"}');
JsonHelper::convertNewLinesToCRLF(array('wo\x0D\x0Arks' => 'fi\x0D\x0Ane'));

Testing

$ composer test

Code checking

$ composer phpstan
$ composer phpstan-max

Security

If you discover any security related issues, please email johnykvsky@protonmail.com instead of using the issue tracker.

Credits

License

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