I am using the Joomla framework API to build a web application. Now I want to display some data from the database in JSON format and I have to change the default HTTP-Content-Type from text/html to application/json. The Joomla framework comes with the Symfony HTTP foundation component, so I've searched the web and found this:
use Symfony\Component\HttpFoundation\Response;
$response = new Response();
$response->headers->set('Content-Type', 'application/json');
$response->send();
But there is no effect.
I have also tried the standard way:
header("Content-Type: application/json");
That doesn't work too..
Thanks for any advice!