The "encode everything in my class"-Code:
public function jsonSerialize()
{
return get_object_vars($this);
}
The JsonSerializable interface
(PHP 5 >= 5.4.0)
Einführung
Objects implementing JsonSerializable can customize their JSON representation when encoded with json_encode().
Interface-Übersicht
Inhaltsverzeichnis
- JsonSerializable::jsonSerialize — Specify data which should be serialized to JSON
Webdev
28-Apr-2012 05:36
