code: public byte[] toJsonUtf8() {
      try {
        ByteArrayOutputStream bOs = new ByteArrayOutputStream(512);
  
        try (JsonGenerator generator = jsonFactory.createJsonGenerator(bOs, JsonEncoding.UTF8)
            .setCodec(objectMapper)) {
          toJsonUtf8(generator);
        }
  
        return bOs.toByteArray();
      } catch (IOException e) {
        throw new RuntimeException("Unexpected IOException serializing to ByteArray", e);
      }
    }
docs: Serialize as a UTF8 encoded JSON string.