PHP code example of originalasm / php-oo-json
1. Go to this page and download the library: Download originalasm/php-oo-json library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
originalasm / php-oo-json example snippets
use OOJson\JSON;
$json = <<<JSON
{
"name": "John Doe",
"number": "12345"
}
JSON
$object = JSON::parse($json);
echo $object->name; // John Doe
echo $ojject->number; // 12345
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"}
`bash
$ composer