On 04.06.2011, at 02:43, John Crenshaw wrote:

> This is a moot point. You wouldn't send that to json_decode. You would send 
> it to json_encode. In other words json_decode({"yay": "ä"}) is totally wrong 
> in the first place, because json_decode requires a string, not an object.

Just to quickly make another point... you couldn't necessarily send this 
"native JSON" construct you and others dream about to json_encode() just like 
that either, since json_encode() too only accepts UTF-8 encoded input.

So if you have a latin1-encoded file (still the default in Eclipse on Windows, 
AFAIK) containing this:

> var_dump(json_encode({"foo": "ä"}));


Then you'll end up with

> string(12) "{"foo":null}"


Which is of course totally consistent with what happens when you do:

> var_dump(json_encode(array("foo" => "ä")));

But try to explain *that* to the average user who doesn't even know what a 
character encoding is.

It's just a totally bad idea. PHP is a language where a good number of people 
still ask questions like "how do I open a new browser window without an address 
bar in PHP" on forums. And now you want to throw yet another language construct 
at them that looks like JSON, but doesn't necessarily behave like it even when 
used with PHP's own JSON functionality, and does not offer any benefit 
whatsoever other than the ability to copy and paste array and object 
declarations between PHP and JS code.

David

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to