2017 © Pedro Peláez
 

library json

A PHP library for manipulate JSON data

image

sgmendez/json

A PHP library for manipulate JSON data

  • Thursday, August 27, 2015
  • by sgmendez
  • Repository
  • 1 Watchers
  • 1 Stars
  • 51 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 2 % Grown

The README.md

License SensioLabsInsight Latest Stable Version Total Downloads Latest Unstable Version, (*1)

# Introduction

This PHP library create a wrapper for json_encode and json_decode PHP functions that normalize use across de PHP versions and throw exceptions when encoding or decoding fail., (*2)

# Requirements

This library require PHP 5.3.3 or higher, (*3)

# Installation

You can use Composer to use this library in your application., (*4)

If you don't have Composer yet, download it following the instructions on http://getcomposer.org/ or just run the following command:, (*5)

curl -s http://getcomposer.org/installer | php

And then execute this command to add libary to your project:, (*6)

$ composer require sgmendez/json

Or require sgmendez/json into your composer.json file:, (*7)

json
{
    "require": {
        "sgmendez/json": "*"
    }
}

# Tests

You can run the PHPUnit tests, in directory test execute:, (*8)

$ php phpunit.phar .

In this directory there are a copy of phpunit.phar for execution test, (*9)

# Examples

Encode JSON data:, (*10)

php
use Sgmendez\Json\Json;

$json = new Json();

try
{
    $arrayData = array('foo' => 'Foo', 'bar' => 'Bar');
    $jsonData = $json->encode($arrayData);
} 
catch (Exception $ex) 
{
    echo '[EXCEPTION] MSG: '.$ex->getMessage().' | FILE: '.$ex->getFile().': '.$ex->getLine()."\n";
}

Decode JSON string (by default, return array data):, (*11)

php
use Sgmendez\Json\Json;

$json = new Json();

try
{
    $jsonData = '{"foo":"Foo","bar":"Bar"}';
    $dataArray = $json->decode($jsonData);
} 
catch (Exception $ex) 
{
    echo '[EXCEPTION] MSG: '.$ex->getMessage() .
         ' | FILE: '.$ex->getFile().': '.$ex->getLine()."\n";
}


Decode JSON file (by default, return array data):, (*12)

php
use Sgmendez\Json\Json;

$json = new Json();

try
{
    $dataArray = $json->decodeFile('/path/to/file.json');
} 
catch (Exception $ex) 
{
    echo '[EXCEPTION] MSG: '.$ex->getMessage() .
         ' | FILE: '.$ex->getFile().': '.$ex->getLine()."\n";
}

If you need to check if is valid json data, you can to use checkValidJsonData() method., (*13)

# License

Licensed under the BSD License:, (*14)

http://opensource.org/licenses/bsd-license.php, (*15)

The Versions

27/08 2015

dev-master

9999999-dev http://sgmendez.github.io/json/

A PHP library for manipulate JSON data

  Sources   Download

BSD-2-Clause

The Requires

  • php >=5.3.3

 

by Salvador Mendez

json encode decode

27/08 2015

v1.0.5

1.0.5.0 http://sgmendez.github.io/json/

A PHP library for manipulate JSON data

  Sources   Download

BSD-2-Clause

The Requires

  • php >=5.3.3

 

by Salvador Mendez

json encode decode

25/08 2015

v1.0.4

1.0.4.0 http://sgmendez.github.io/json/

A PHP library for manipulate JSON data

  Sources   Download

BSD-2-Clause

The Requires

  • php >=5.3.3

 

by Salvador Mendez

json encode decode

06/04 2015

v1.0.3

1.0.3.0 http://sgmendez.github.io/json/

A PHP library for manipulate JSON data

  Sources   Download

BSD-2-Clause

The Requires

  • php >=5.3.3

 

by Salvador Mendez

json encode decode

06/04 2015

v1.0.2

1.0.2.0 http://sgmendez.github.io/json/

A PHP library for manipulate JSON data

  Sources   Download

BSD-2-Clause

The Requires

  • php >=5.3.3

 

by Salvador Mendez

json encode decode

18/03 2015

v1.0.1

1.0.1.0 http://sgmendez.github.io/json/

A PHP library for manipulate JSON data

  Sources   Download

BSD-2-Clause

The Requires

  • php >=5.3.3

 

by Salvador Mendez

json encode decode

18/03 2015

v1.0.0

1.0.0.0 https://github.com/sgmendez/json

A PHP library for manipulate JSON data

  Sources   Download

BSD-2-Clause

The Requires

  • php >=5.3.3

 

by Salvador Mendez

json encode decode

18/03 2015

v1.0.0-beta

1.0.0.0-beta https://github.com/sgmendez/json

A PHP library for manipulate JSON data

  Sources   Download

BSD-2-Clause

The Requires

  • php >=5.3.3

 

by Salvador Mendez

json encode decode