2
Sometimes I noticed that Docs suggests that instead of using the native method \json_encode()
from PHP, he suggests using a class method for requests that apparently does the same thing \GuzzleHttp\json_encode()
, but giving a read in the files of this class I found the following method:
function json_encode($value, $options = 0, $depth = 512)
{
$json = \json_encode($value, $options, $depth);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException(
'json_encode error: ' . json_last_error_msg());
}
return $json;
}
I had never entered any parameters in json_encode(), the doubt is the question title:
- What the Depth parameter does when encoding a string ?
So reporting 512 (which is usually what I’m seeing) is totally unnecessary ?
– AnthraxisBR
It has its usefulness, you may want to explicitly limit the recursion limit for some reason
– Artur Trapp