How can the output of json_decode in PHP be properly formatted for easier debugging?
When using json_decode in PHP, the output may be difficult to read and debug due to its unformatted structure. To make the output more readable, you can use the JSON_PRETTY_PRINT option as the second parameter of json_decode. This will format the output with indentation and line breaks, making it easier to analyze.
$jsonString = '{"key1":"value1","key2":"value2"}';
$decodedData = json_decode($jsonString, true, JSON_PRETTY_PRINT);
var_dump($decodedData);