PHP code example of vanengers / php-json-object-library
1. Go to this page and download the library: Download vanengers/php-json-object-library 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/ */
vanengers / php-json-object-library example snippets
class SamplePhpObject extends PhpJsonObject
{
public string $property = 'value';
public function setProperty(string $data): self
{
$this->property = $value;
// do stuff here like parsing data, transformation or validations
return $this;
}
}
class SamplePhpObject extends PhpJsonObject
{
public $mappers = [
'person_name' => 'author',
'recipient_name' => 'recipient',
];
public string $author = '';
public string $recipient = '';
public function setPerson($data)
{
if (is_array($data)) {
$this->fromArray($data);
}
}
public function setRecipient($data)
{
if (is_array($data)) {
$this->fromArray($data);
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.