@Override
    public HttpResponse convertResponse(ServiceRequestContext ctx,
                                        ResponseHeaders headers,
                                        @Nullable Object result,
                                        HttpHeaders trailers) throws Exception {
        final MediaType mediaType = headers.contentType();
        if (mediaType != null) {
            // @Produces("application/json") or @ProducesJson is specified.
            // Any MIME type which ends with '+json' such as 'application/json-patch+json' can be also accepted.
            if (mediaType.isJson()) {
                final Charset charset = mediaType.charset(StandardCharsets.UTF_8);
                // Convert the object only if the charset supports UTF-8,
                // because ObjectMapper always writes JSON document as UTF-8.
                if (charset.contains(StandardCharsets.UTF_8)) {
                    if (result instanceof Publisher) {
                        return aggregateFrom((Publisher<?>) result, headers, trailers,
                                             this::toJsonHttpData, ctx);
                    }
                    if (result instanceof Stream) {
                        return aggregateFrom((Stream<?>) result, headers, trailers,
                                             this::toJsonHttpData, ctx.blockingTaskExecutor());
                    }
                    return HttpResponse.of(headers, toJsonHttpData(result), trailers);
                }
            }

            // @Produces("application/json-seq") or @ProducesJsonSequences is specified.
            if (mediaType.is(MediaType.JSON_SEQ)) {
                if (result instanceof Publisher) {
                    return JsonTextSequences.fromPublisher(headers, (Publisher<?>) result, trailers, mapper);
                }
                if (result instanceof Stream) {
                    return JsonTextSequences.fromStream(headers, (Stream<?>) result, trailers,
                                                        ctx.blockingTaskExecutor(), mapper);
                }
                return JsonTextSequences.fromObject(headers, result, trailers, mapper);
            }
        } else if (result instanceof JsonNode) {
            // No media type is specified, but the result is a JsonNode type.
            return HttpResponse.of(headers.toBuilder().contentType(MediaType.JSON_UTF_8).build(),
                                   toJsonHttpData(result), trailers);
        }

        return ResponseConverterFunction.fallthrough();
    }
Creates an instance with the specified {@link ObjectMapper}.
core/src/main/java/com/linecorp/armeria/server/annotation/JacksonResponseConverterFunction.java