The "encode everything in my class"-Code:
public function jsonSerialize()
{
return get_object_vars($this);
}
The JsonSerializable interface
(PHP 5 >= 5.4.0)
Wstęp
Objects implementing JsonSerializable can customize their JSON representation when encoded with json_encode().
Zestawienie interfejsu
Spis treści
- JsonSerializable::jsonSerialize — Specify data which should be serialized to JSON
Webdev
29-Apr-2012 02:36
