Re: json_encode()
| From: | Alexey Zakhlestin | Date: | Tue, 16 Dec 2008 12:23:37 +0000 |
| Subject: | Re: json_encode() | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42288@lists.php.net to get a copy of this message | ||
On Tue, Dec 16, 2008 at 3:20 PM, troels knak-nielsen <troelskn@gmail.com> wrote:
> On Tue, Dec 16, 2008 at 12:57 PM, Scott MacVicar <scott@macvicar.net> wrote:
>> For now I'll be leaving it as is and adding a JSON_STRICT_ENCODE
>> parameter to the options flag. So you can use
>>
>> json_encode($var, JSON_STRICT_ENCODE);
>>
>
> I'm really not a fan of named constants to change the semantics of a
> function like that. Not to mention that it's a pita to type out, so
> nobody would bother. It also doesn't address the crux of the matter -
> That the name json_encode is slightly misleading, in that it may or
> may not emit json.
>
> Would it be a problem to introduce a second function (js_encode?)
> instead? It could work as json_encode does today, and json_encode
> could then be changed to raise a warning on illegal input. I realise
> that this means breaking existing scripts, but it's a trivial change,
> and if it's announced in advance, people should have time to make that
> sed -r '/json_encode/js_encode/g' to their code base.
sounds like a proper way to me
--
Alexey Zakhlestin
http://www.milkfarmsoft.com/