normeno/gjson

Generate output based on Google JSON style guide

v1.0.9 2017-11-07 16:33 UTC

This package is not auto-updated.

Last update: 2025-06-05 12:29:24 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Gjson is a PHP library to work under the Google Json Style Guide standard.

Install

Via Composer

$ composer require normeno/gjson

Usage

Remove Empties

$format = new Format();
echo $format->removeEmpty(['foo' => 'bar', 'null' => null, 'empty' => '', 'zero' => 0]);

Set RFC3339

$format = new Format();
echo $format->setRfc3339('1989-10-05');

Convert Snake to Camel

$format = new Format();
echo $format->convertSnakeToCamel([
    'laTaM_cOuNtRy' => 'Chile',
    'latam_REGION'  => 'Metropolitana',
    'LATAM_city'    => 'Santiago'
]);

Set ISO-6793

$format = new Format();
echo $format->setIso6709(['+40.6894', '-074.0447']);

Error Response

$response = new Response();
echo $this->response->error(404, 'File Not Found');

Success Response

$response = new Response();
$data = [
    'items' => [
        'company'   => 'Google',
        'website'   => 'https://www.google.com/'
    ]
];

echo $this->response->success($data);

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email ni.ormeno@gmail.com instead of using the issue tracker.

Credits

License

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