On Mon, Dec 15, 2008 at 9:50 AM, Rasmus Lerdorf <ras...@lerdorf.com> wrote:

> 1. Document the fact that if you want to strictly conform to the JSON
>   spec and be sure your json_encode output will work in various JSON
>   parsers, you have to pass it a PHP array or object.

Instead of json_encode(34) the suggestion would be
json_encode(array(34)) ? Seems kind of like a lame thing to require.
IMHO the language should "do the right thing" as far as the consumer
(javascript/JSON parser) is concerned. However, Douglas is infinitely
more educated than I am here. This is just my $0.02 as a PHP user.

> 2. Remove support for basic types entirely and throw an error if you
>   pass json_encode() something that is not an array or an object.
>
> 3. Wrap basic types in an array [] by default and perhaps add an option
>   to json_encode() to skip the wrapper.

This sounds like what I had been talking about previously.

> He would prefer option 1.

I'd be tempted to say #3. However that's probably a code change
everyone must make, I would expect that to be in a major release like
6.0.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to