https://bugs.php.net/bug.php?id=75400 is asking for a version of
JsonSerializable which doesn't involve deserializing/reserialzing
round trips when a chunk of JSON is known in advance.
It's not terribly unreasonable IMO, but before I just writeup the RFC
as described (jsonRawSerialize taking preceedence over jsonSerialize),
I thought I'd ask for opinions on the specifics.
In psuedo-code:
if (is_object($obj)) {
if ($obj implements JsonRawSerializable) {
// use $obj->jsonRawSerialize() as is.
} elseif ($obj implements JsonSerializble) {
// use json_encode($obj->jsonSerialize())
} else {
// Serialize the object's public properties as a key/value map
}
}
Perhaps with the stipulation that if jsonRawSerialize() returns null,
we'd fallback on jsonSerialize(). Any other non-string results in an
encoding error.
-Sara
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php