I\'m building a PHP script that feeds JSON data to another script. My script builds data into a large associative array, and then outputs the data using json_encode
Many users suggested that you use
echo json_encode($results, JSON_PRETTY_PRINT);
Which is absolutely right. But it's not enough, the browser needs to understand the type of data, you can specify the header just before echo-ing the data back to the user.
header('Content-Type: application/json');
This will result in a well formatted output.
Or, if you like extensions you can use JSONView for Chrome.