note 109425 deleted from class.jsonserializable by danbrown

From: Date: Mon, 16 Jul 2012 14:59:23 +0000
Subject: note 109425 deleted from class.jsonserializable by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189161@lists.php.net to get a copy of this message
Note Submitter: mindplay.dk ---- Note that while the JsonSerializable interface enables you to serialize an object to a JSON string-representation using json_encode(), there is currently no counterpart for de-serialization. Also note that, by default, the class-name of the serialized object isn't stored, so technically there would be no way to de-serialize an object-graph from a string-representation. Although you could of course store the class-name by returning it via the JsonSerializable interface, that still does not provide a mechanism for de-serialization. I wrote the following class, which performs serialization and de-serialization in JSON format, by storing the class-name in a reserved '#type' property in JSON objects: http://github.com/mindplay-dk/jsonfreeze/blob/master/mindplay/jsonfreeze/JsonSerializer.php This does have some limitations, which are discussed here: http://stackoverflow.com/questions/10489876

« previous php.notes (#189161) next »