package hello;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.net.MediaType;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.util.Headers;

import java.util.Collections;
import java.util.Objects;

import static hello.HelloWebServer.JSON_UTF8;

/**
 * Handles the JSON test.
 */
final class JsonHandler implements HttpHandler {
  private final ObjectMapper objectMapper;

  public JsonHandler(ObjectMapper objectMapper) {
    this.objectMapper = Objects.requireNonNull(objectMapper);
  }

  @Override
  public void handleRequest(HttpServerExchange exchange) throws Exception {
    exchange.getResponseHeaders().put(
        Headers.CONTENT_TYPE, JSON_UTF8);
    exchange.getResponseSender().send(
        objectMapper.writeValueAsString(
            Collections.singletonMap("message", "Hello, World!")));
  }
}

@@ -216,24 +216,52 @@
 l.Headers;%0A%0A
+import java.nio.ByteBuffer;%0A
 import java.
@@ -803,25 +803,44 @@
 ().send(
-%0A
+ByteBuffer.wrap(%0A   
         
 objectMa
@@ -831,16 +831,17 @@
         
+ 
 objectMa
@@ -861,16 +861,23 @@
 ueAs
-String(%0A
+Bytes(%0A        
     
@@ -938,16 +938,17 @@
 rld!%22)))
+)
 ;%0A  %7D%0A%7D%0A

Change to use writeValueAsBytes