ID: 38680
Updated by: [email][/email]
Reported By: RQuadling at GMail dot com
-Status: Critical
+Status: Assigned
-Bug Type: Doentation problem
+Bug Type: Unknown/Other Function
Operating System: Windows XP SP2
-PHP Version: Irrelevant
+PHP Version: 5.2
-Assigned To:
+Assigned To: ilia
New Comment:

reclassified & assigned to Ilia

Previous Comments:

[2006-09-24 00:21:07] [email][/email]

This is a doentation issue that must (should) be resolved before PHP
5.2 is released. The current docs were taken straight out of the README
that's within the json extension sources.

Please summarize exactly what needs to be changed here.


[2006-09-04 08:55:41] RQuadling at GMail dot com

Why is this bogus? I've reopened it as the PHP Dox makes no mention of
the restriction that only objects and arrays are encodable/decodable.
And if the json_encode only dealt with arrays & objects rather than all
types except resources, then the code would be cleaner and give less


[2006-09-01 14:43:33] RQuadling at GMail dot com

I'm not sure I follow. I'm reading the PHP doc and json_encode says it
can encode _ANY_ type except resource.

json_decode says it "takes a JSON encoded string and converts it into a
PHP variable".


$m_var = json_decode(json_decode($m_original_var));

$m_var == $m_original_var.
Maybe NOT ===, but at least ==

So, there are several issues here.

json_encode says ANY type. Not just objects or arrays. Admittedly, an
array with int/bool/null in all work fine as does a multi-dimensional

If the dox said JUST arrays and objects, then that would be fine too.
You could then emit a warning when the types supplied wasn't an array
or an object.

But, as it stands, the dox say __ANY__, so, it is VERY reasonable to
assume that encoding boolean/integers/null via json_encode will produce
something usable.

AND json_decode says it will decode any json_encoded string. Now, at
this stage, I'm not even using the data, I'm just encoding it and then
instantly decoding it. Not via a browser or JS. Just all in PHP. And
this is not working.

In your reply you say that "true/false/null/numerics in raw form are
not valid JSON structures, so json_decode will reject them and output
NULL" - Fair enough, but not what my bug report is about.

I'm saying that json_encode is NOT producing correctly encoded
structures for json_decode, NOT that I'm manually creating these
structures and expecting them to work.




Very much NOT what would be expected!


[2006-09-01 14:25:21] [email][/email]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the doentation available at
[url][/url] and the instructions on how to report
a bug at [url][/url]

This is a doentation issue...

true/false/null/numerics in raw form are not valid JSON structures, so
json_decode will reject them and output NULL.

Basically, if JSON_checker ([url][/url]) says
something is invalid JSON, then json_decode will return NULL.

json_encode emits true/false/etc as any other way makes even less
sense. :)


[2006-09-01 13:30:31] [email][/email]

Omar: really a doc issue?


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

Edit this bug report at [url][/url]