Because I prefer a more object oriented approach I wrote my own json class to handle also json_last_error for decode and encode.
Somehow I get a php warning for the depth property of the json_decode method.
The PHP core api (eclipse PDT) for the json_decode method looks like the following:
function json_decode ($json, $assoc = null, $depth = null) {}
So far so good but if I write my own class like this:
function my_json_decode ($json, $assoc = null, $depth = null) {
return json_decode($json, $assoc, $depth);
}
and try to run it as follow:
$json = '{ "sample" : "json" }';
var_dump( my_json_decode($json) );
I get the following warning:
Warning: json_decode(): Depth must be greater than zero in /
Did I miss anything? I thought if I pass null for a property to a method which set the property itself to null it should be fine?!
Using: Server: Apache/2.2.22 (Unix) PHP/5.3.10
Thanks for the help!
[Edit] to clarify where my leak of understanding was:
I am using Eclipse Indigo + PDT. The PDT PHP core api of org.eclipse.php.core.language is different from what php.net say about json_decode:
json_decode org.eclipse.php.core.language:
json_decode ($json, $assoc = null, $depth = null)
json_decode php.net:
json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] )