2017 © Pedro Peláez
 

library php-oo-json

An Object Oriented wrapper for the PHP JSON parser

image

originalasm/php-oo-json

An Object Oriented wrapper for the PHP JSON parser

  • Thursday, October 13, 2016
  • by amitosh
  • Repository
  • 1 Watchers
  • 0 Stars
  • 844 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 8 % Grown

The README.md

php-oo-json

An object oriented wrapper for internal PHP json support, (*1)

Contains methods for parsing JavaScript Object Notation (JSON) and converting values to JSON. It can't be constructed and contains no properties or constants of its own. Aside from its two method properties it has no interesting functionality of its own., (*2)

The JSON::parse and JSON::stringify methods are mere OO wrappers around json_decode and json_encode PHP functions., (*3)

See http://php.net/manual/en/book.json.php, (*4)

Usage

Installation

$ composer require originalasm/php-oo-json

Simple JSON parsing

require 'vendor/autoload.php'

use OOJson\JSON;

$json = <<<JSON
{
    "name": "John Doe",
    "number": "12345"
}
JSON

$object = JSON::parse($json);

echo $object->name;     // John Doe
echo $ojject->number;   // 12345

Simple JSON stringify

require 'vendor/autoload.php'

use OOJson\JSON;

class User {

    public $name;
    public $number;

    public function __construct(/* string */ $name, /* number */ $number) {
        $this->name = $name;
        $this->number = $number;
    }
}

$object = new User("John Doe", 123456);

$json = JSON::stringify($object);

echo $json;     // {"name":"John Doe","number":"12345"}

LICENSE

Copyright (c) 2016, Amitosh Swain Mahapatra, (*5)

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies., (*6)

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE., (*7)

The Versions

13/10 2016

dev-master

9999999-dev

An Object Oriented wrapper for the PHP JSON parser

  Sources   Download

ISC

The Requires

  • php >=5.2.0

 

by Amitosh Swain Mahapatra

13/10 2016

v1.0.1

1.0.1.0

An Object Oriented wrapper for the PHP JSON parser

  Sources   Download

ISC

The Requires

  • php >=5.2.0

 

by Amitosh Swain Mahapatra

09/06 2016

v1.0.0

1.0.0.0

An Object Oriented wrapper for the PHP JSON parser

  Sources   Download

ISC

The Requires

  • php >=5.2.0

 

by Amitosh Swain Mahapatra