Return a new JSON response from the application.
$data = array( "name" => "John Doe", "email" => "jdoe@example.com", "age" => 30 ); $json = json_encode($data); echo $json;
$json = '{"name":"John Doe","email":"jdoe@example.com","age":30}'; $data = json_decode($json); echo $data->name;In this example, we have a JSON string that we want to decode into a PHP object. We use the `json_decode()` function to do this, and then access the `name` property of the resulting object. Package/Library: PHP Response JSON is part of the core PHP library and does not require any additional packages or libraries.