Re: Inconsistent json_decode() results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5 May 2010 20:02, Michael Shadle <mike503@xxxxxxxxx> wrote:

> 2010/5/5 Michiel Sikma <michiel@xxxxxxxxxxxxxx>:
>
> > By the way, if you're stuck on 5.2.10, you could simply cast the result
> to
> > array:
> >
> > var_dump((array)json_decode('{"_urls": ["a", "b"]}'));
>
> I don't see a "available starting in 5.x.x" notice, so I think it's
> been there for a long time...
>
> http://www.php.net/json_decode
>

You're right, but this is about how 5.2.10 ignores the second parameter and
always returns a class, which appears to be a bug. I'm not sure which other
versions have this same problem, but 5.2.11 has correct behavior, which
seems to suggest they found and fixed it by then. I can't find an entry for
this problem in PHP's bug database, however.

My suggestion to typecast the result of json_decode() should only be
followed if you need an array and are required to work with version 5.2.10.

Michiel

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux