json_encode if the header is set for json