- get_object_vars: documentation ( source)
- json_encode: documentation ( source)
<?php
abstract class AbstractEvent
{
protected $id;
private $hidden;
}
final class Event extends AbstractEvent implements JsonSerializable
{
private $value;
public function __construct()
{
$this->id = 5;
$this->value = 'abc';
}
public function jsonSerialize()
{
return get_object_vars($this);
}
}
$e = new Event();
echo json_encode($e);