$remote->json()
Decode the response content
Name |
Type |
Default |
Description |
$array |
bool |
true |
decode as array or object |
stdClass
|array
|null
Kirby\Http\Remote
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: