$remote->json()
Decode the response content
Parameters
Name | Type | Default | Description |
---|---|---|---|
$array | bool |
true |
decode as array or object |
Return type
stdClass
|array
|null
Parent class
Example
If the respons content is a JSON response, you can use the $remote->json()
method to covert the content to an array or object.
In this example, we get list of UK holidays from a freely accessible API and convert the JSON response to an array:
If you prefer to work with an object instead of an array, set the $array
parameter to false
. Here we get a list of historical US newspapers: