3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test implements JsonSerializable { private $name = 'Mike Jones'; public function jsonSerialize() { return [ 'name' => $this->name, 'fooo' => ['year' => 2003, 'type' => 'single'] ]; } } var_dump(json_encode(new Test()));
based on PUrva
Output for 5.5.0 - 7.3.0rc3
string(58) "{"name":"Mike Jones","fooo":{"year":2003,"type":"single"}}"