Re: json_encode() bug

From: Date: Tue, 05 Feb 2008 22:19:30 +0000
Subject: Re: json_encode() bug
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-35201@lists.php.net to get a copy of this message
On Sun, February 3, 2008 7:51 pm, Stanislav Malyshev wrote: >> Like I mentioned before (I think), it should not return an empty >> string >> of course because programmatically it's not possible to check for >> this. >> As most of our functions return false in those cases, so should this >> function. > > AFAIR false is not valid JSON, so it would break a lot of code. Also, > I > am not sure we should change json_encode to return false on whole > structure if one of the fields contains invalid utf-8. I see what you are saying, but... If you want to write good quality code, you have to do something reasonable here. PERHAPS: Return false E_WARNING Put partially decoded value somewhere in a variable to be accessed, so that the programmer can make an informed decision about what to do. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So?

« previous php.internals (#35201) next »