PHP code example of php-alchemist / json
1. Go to this page and download the library: Download php-alchemist/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/ */
php-alchemist / json example snippets
class Demo {
public string $test;
public string $doSomething;
}
$json = '{"test":"blah","doSomething":"asdf"}';
$mapper = new PHPAlchemist\Json\Service\JsonMapper();
$asdf = $mapper->map($json, Demo::class);
var_dump($asdf);
object(Demo)#1 (2) {
["test"]=>
string(4) "blah"
["doSomething"]=>
string(4) "asdf"
}