Re: json_encode()

From: Date: Tue, 16 Dec 2008 06:34:13 +0000
Subject: Re: json_encode()
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-42279@lists.php.net to get a copy of this message
Hi, JSON allows extensions. I can not understand why this is not an extension that makes sense: json_encode($var, $allowScalar = false); In PHP outputting of JS literals is a common action, so all you'll achieve by completely removing this option, is forcing people to go from this: echo 'var foo = '.json_encode("hello world"); ...to this: echo 'var foo = '.substr(json_encode(array("hi world")), 1, -1); A flag that defaults to false would be just as explicit and educational, and more efficient, than forcing hacks on us like the above one. Regards, Stan Vassilev

« previous php.internals (#42279) next »