Re: Re: svn: /php/php-src/trunk/ NEWS ext/json/json.c ext/json/php_json.h ext/json/tests/serialize.phpt
| From: | Pierre Joye | Date: | Wed, 12 May 2010 10:32:42 +0000 |
| Subject: | Re: Re: svn: /php/php-src/trunk/ NEWS ext/json/json.c ext/json/php_json.h ext/json/tests/serialize.phpt | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48266@lists.php.net to get a copy of this message | ||
hi!
On Wed, May 12, 2010 at 4:25 AM, Stanislav Malyshev <stas@zend.com> wrote:
> Hi!
>
>> Add JSON_Serializable interface
>> Objects implementing JSON_Serializable will have
>> their ->jsonSerialize() method called
>>
>> Similar to serialize() and __sleep()
>
> Why should we have special mechanism for JSON? I.e., now we have one for
> serialize(), separate one for json, then we'd have separate one for storing
> object as XML or YAML, etc. etc. IMHO it's not a very good design - having
> separate method for every format of data storage. Why can't we just use
> whatever serialize() would see and wrap it in JSON after that?
Serialize is a different thing but Json seems to be standard enough to
justify a __toJson method. In any case, using _ in classes name is a
no go, as we decided a while back. We can call JsonSerializable if we
keep the interface instead of moving this feature to __toJson (which I
prefer).
Cheers,
--
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org