Re: json_encode()

From: Date: Mon, 15 Dec 2008 21:02:29 +0000
Subject: Re: json_encode()
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-42271@lists.php.net to get a copy of this message
On Mon, Dec 15, 2008 at 12:55 PM, Uwe Schindler <thetaphi@php.net> wrote: > As is noted in an earlier mail, I would prefer 1 (simply document it in the > function description). In my opinion, if somebody then passes a basic type > to json_encode he is aware of what he is doing (hopefully). > > For compatibility with current code and securely escaping strings for > javascript it is the best. PHP 6 will require some recoding for various things. I'd like to see it "do the right thing" in PHP 6, and perhaps if people are using json_encode for escaping, make another function that is there purely for escaping javascript, not serializing/unserializing it for direct exchange with JSON consumption in javascript. After all, this is json_encode, not javascript_escape ... I was unaware that json_encode() [improperly] encoded non-arrays/objects, as I expected those details to be worked out in the implementation. While it does produce legitimate javascript it does not produce legitimate JSON, which is the purpose of these functions, no?

« previous php.internals (#42271) next »