1. Go to this page and download the library: Download karriere/json-decoder 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/ */
karriere / json-decoder example snippets
#[AllowDynamicProperties]
class Person
{
public int $id;
public string $name;
public ?string $lastname = '';
}
class Person
{
public int $id;
public string $name;
public mixed $address;
}
class PersonTransformer implements Transformer
{
public function register(ClassBindings $classBindings)
{
$classBindings->register(new FieldBinding('address', 'address', Address::class));
}
public function transforms()
{
return Person::class;
}
}