From 959be50e8be3f363f10ae684f6a889112064e29b Mon Sep 17 00:00:00 2001 From: "Herman J. Radtke III" Date: Wed, 10 Sep 2008 01:51:18 +0000 Subject: [PATCH] Added an example showing some common problems people using JavaScript run into when using json_decode. Also added a note stating that JSON is not the same as JavaScript in hopes that people will realize that the json_decode function is not buggy but instead following the JSON specification. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@266054 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/json/functions/json-decode.xml | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/reference/json/functions/json-decode.xml b/reference/json/functions/json-decode.xml index c40b5d1a3d..8bcef3b195 100644 --- a/reference/json/functions/json-decode.xml +++ b/reference/json/functions/json-decode.xml @@ -1,5 +1,5 @@ - + json_decode @@ -100,6 +100,31 @@ $json = '{"foo-bar": 12345}'; $obj = json_decode($json); print $obj->{'foo-bar'}; // 12345 +?> +]]> + + + + common mistakes using <function>json_decode</function> + + ]]> @@ -109,6 +134,11 @@ print $obj->{'foo-bar'}; // 12345 &reftitle.notes; + + + The JSON spec is not JavaScript, but a subset of JavaScript. + + This function will return false if the JSON encoded data is deeper than