PHP code example of thevenrex / json-to-class
1. Go to this page and download the library: Download thevenrex/json-to-class 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/ */
thevenrex / json-to-class example snippets
use Thevenrex\JsonToClass\JsonToClassDecoder;
class User {
public int $id;
public string $name;
public string $username;
}
$json = '{
"id": 1,
"name": "John Doe",
"username": "johndoe"
}';
$decoder = new JsonToClassDecoder($rawJson);
$user = new User();
$decoder->decode($user);
var_dump($user);