Comments on: PHP and JSON: Cut #987 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/ The Killersoft Blog by Clay Loveless Wed, 20 Aug 2008 11:43:04 +0000 http://wordpress.org/?v=2.2.3 By: Paul M. Jones » Blog Archive » Memory Leaks With Objects in PHP 5 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-41472 Paul M. Jones » Blog Archive » Memory Leaks With Objects in PHP 5 Fri, 28 Sep 2007 13:09:23 +0000 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-41472 [...] Problem is that it didn’t garner many votes for inclusion in 5.3. Clay Loveless talked about death by 1000 cuts a while ago; this feels like it might be cut [...] […] Problem is that it didn’t garner many votes for inclusion in 5.3. Clay Loveless talked about death by 1000 cuts a while ago; this feels like it might be cut […]

]]>
By: Lukas http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8548 Lukas Fri, 02 Mar 2007 20:57:00 +0000 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8548 Unfortunately thats the reality. However, this reality still did not stop php from getting where it is today. If you tell me which developer you spoke to, I can also see what I can do. Feel free to email me. Unfortunately thats the reality. However, this reality still did not stop php from getting where it is today. If you tell me which developer you spoke to, I can also see what I can do. Feel free to email me.

]]>
By: Clay http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8528 Clay Fri, 02 Mar 2007 09:28:08 +0000 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8528 @Lukas: You make it sound so much like high school, complete with cliques and everything. :) This is a significant part of what's wrong with PHP. The case is made quite clear by the JSON Checker and the test suite it provides. The suggestion that one has to suck up to the _right_ group to get PHP's JSON extension to behave like the JSON Checker is very illuminating. @Lukas: You make it sound so much like high school, complete with cliques and everything. :)
This is a significant part of what’s wrong with PHP.

The case is made quite clear by the JSON Checker and the test suite it provides. The suggestion that one has to suck up to the _right_ group to get PHP’s JSON extension to behave like the JSON Checker is very illuminating.

]]>
By: Lukas http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8512 Lukas Thu, 01 Mar 2007 22:45:53 +0000 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8512 Ah ok .. I get it now. However the "internals team" is not such a homogeneous bunch as you make it sound. Unfortunately decisions are often not thought through all the way. So if you feel strongly about something try to softly check up the issue with multiple people. It pays to know the internal cliques as well. Not easy to dig through from the outside unfortunately :-/ Anyways usually php.net tries to follow standards. I do not know if there was any reaction so far from anyone with the necessary karma. One more thing to note: While single developers have the say over their respective pecl packages, this changes once the code goes into core, at which point more people can influence the direction of the code. So without being a JSON expert myself, try to make your case clear and I think you should have a good shot at getting this fixed for 5.2.2. Also please consider phpt'ing your unit tests to prevent such breakage in the future. Ah ok .. I get it now.

However the “internals team” is not such a homogeneous bunch as you make it sound. Unfortunately decisions are often not thought through all the way. So if you feel strongly about something try to softly check up the issue with multiple people. It pays to know the internal cliques as well. Not easy to dig through from the outside unfortunately :-/

Anyways usually php.net tries to follow standards. I do not know if there was any reaction so far from anyone with the necessary karma.

One more thing to note: While single developers have the say over their respective pecl packages, this changes once the code goes into core, at which point more people can influence the direction of the code. So without being a JSON expert myself, try to make your case clear and I think you should have a good shot at getting this fixed for 5.2.2. Also please consider phpt’ing your unit tests to prevent such breakage in the future.

]]>
By: developercast.com » Blog Archive » Clay Loveless’ Blog: PHP and JSON: Cut #987 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8500 developercast.com » Blog Archive » Clay Loveless’ Blog: PHP and JSON: Cut #987 Thu, 01 Mar 2007 15:20:59 +0000 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8500 [...] a new post today, Clay Loveless talks about some issues he’s been having with PHP and JSON, specifically [...] […] a new post today, Clay Loveless talks about some issues he’s been having with PHP and JSON, specifically […]

]]>
By: Clay http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8499 Clay Thu, 01 Mar 2007 15:19:18 +0000 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8499 @Lukas: Please click on <a href="http://bugs.php.net/bug.php?id=38440" rel="nofollow">the link for the bug</a> if you really want to know what happened with the initial bug report. I opened a bug related to PHP 5.2.0RC1 and the decoding issue. I then dug deeper into the way JSON should work (according to the <a href="http://www.json.org/JSON_checker" rel="nofollow">JSON Checker</a> test suite), and declared my bug bogus. Then PHP 5.2.1 came along, and the behavior changed. As I mentioned in the post, and Paul mentioned <a href="#comment-8464" rel="nofollow">above</a>, some pre-bug-filing conversations were had about this new behavior, and the internals team made this change intentionally. They do not consider the PHP 5.2.1 behavior to be buggy or broken. @Lukas: Please click on the link for the bug if you really want to know what happened with the initial bug report.

I opened a bug related to PHP 5.2.0RC1 and the decoding issue. I then dug deeper into the way JSON should work (according to the JSON Checker test suite), and declared my bug bogus.

Then PHP 5.2.1 came along, and the behavior changed. As I mentioned in the post, and Paul mentioned above, some pre-bug-filing conversations were had about this new behavior, and the internals team made this change intentionally. They do not consider the PHP 5.2.1 behavior to be buggy or broken.

]]>
By: Lukas http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8498 Lukas Thu, 01 Mar 2007 15:07:35 +0000 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8498 @Lukas: I didn’t get a response, because I closed the bug as ‘bogus’ — I’d determined that a NULL decoding was in fact what I should have gotten. I dont understand that sentence. Didnt you say that it does not return NULL. So why did _you_ bogus your own bug? /me is confused @Lukas: I didn’t get a response, because I closed the bug as ‘bogus’ — I’d determined that a NULL decoding was in fact what I should have gotten.

I dont understand that sentence. Didnt you say that it does not return NULL. So why did _you_ bogus your own bug?

/me is confused

]]>
By: Paul M. Jones » Blog Archive » Solar 0.27.0 and 0.27.1 Released http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8497 Paul M. Jones » Blog Archive » Solar 0.27.0 and 0.27.1 Released Thu, 01 Mar 2007 14:49:50 +0000 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8497 [...] we now have the fastest and most-compliant JSON encoder/decoder in the PHP universe, thanks to Clay Loveless. It uses ext/json but does a little pre-checking to make sure the strings to be decoded are [...] […] we now have the fastest and most-compliant JSON encoder/decoder in the PHP universe, thanks to Clay Loveless. It uses ext/json but does a little pre-checking to make sure the strings to be decoded are […]

]]>
By: Patrick Mueller http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8496 Patrick Mueller Thu, 01 Mar 2007 14:08:47 +0000 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8496 RFC 4627 is not a standard. From the document itself: "This memo provides information for the Internet community. It does not specify an Internet standard of any kind." It's a bit ridiculous to only support objects and arrays with a decoder. It would be easy enough to support number, string, boolean and null as well, and then the user of the API make a determination of whether the resultant type is appropriate. Or add a flag to limit filter the result for you (returning an error condition). As an earlier commented noted, the way of the web is: "be liberal in what you accept". Of particular importance, it appears, given this blog entry, that json_decode() function returns NULL on errors. That's pretty bad. Since null is a perfectly valid value in JSON. Even if this API never returns anything but array / object, it's not immediately obvious, without looking at the doc that this would be the case. Someone might do a quick test and find json_decode('null') returns NULL and think - woot! it handles nulls! When of course it doesn't. This would have been a good case for using an exception in the API. Or returning an error object you could sniff for. Or something. NULL is just bad. RFC 4627 is not a standard. From the document itself: “This memo provides information for the Internet community. It does not specify an Internet standard of any kind.”

It’s a bit ridiculous to only support objects and arrays with a decoder. It would be easy enough to support number, string, boolean and null as well, and then the user of the API make a determination of whether the resultant type is appropriate. Or add a flag to limit filter the result for you (returning an error condition). As an earlier commented noted, the way of the web is: “be liberal in what you accept”.

Of particular importance, it appears, given this blog entry, that json_decode() function returns NULL on errors. That’s pretty bad. Since null is a perfectly valid value in JSON. Even if this API never returns anything but array / object, it’s not immediately obvious, without looking at the doc that this would be the case. Someone might do a quick test and find json_decode(’null’) returns NULL and think - woot! it handles nulls! When of course it doesn’t. This would have been a good case for using an exception in the API. Or returning an error object you could sniff for. Or something. NULL is just bad.

]]>
By: PHPDeveloper.org http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8495 PHPDeveloper.org Thu, 01 Mar 2007 13:56:46 +0000 http://killersoft.com/randomstrings/2007/02/28/php-and-json-cut-987/#comment-8495 <strong>Clay Loveless' Blog: PHP and JSON: Cut #987...</strong> ... Clay Loveless’ Blog: PHP and JSON: Cut #987…

]]>