$json_input = file_get_contents('php://input'); $data = json_decode($json_input); print_r($data);
$json_input = file_get_contents('data.json'); $data = json_decode($json_input, true); $data['name'] = 'John Doe'; $json_output = json_encode($data); file_put_contents('data.json', $json_output);In this example, the JSON data is read from a file named `data.json` using the `file_get_contents` function. The decoded data is then manipulated by changing the value of the `name` key to 'John Doe'. Finally, the updated JSON data is encoded back into a JSON string using the `json_encode` function and written back to the file using the `file_put_contents` function. Package library: The package library used in these examples is the built-in `json` library of PHP, which provides functions for encoding and decoding JSON data.