Only send the JSON header if headers haven't already been sent