diff --git a/src/main/java/org/wiremock/grpc/internal/JsonMessageConverter.java b/src/main/java/org/wiremock/grpc/internal/JsonMessageConverter.java index 44ec61b..a9e312e 100644 --- a/src/main/java/org/wiremock/grpc/internal/JsonMessageConverter.java +++ b/src/main/java/org/wiremock/grpc/internal/JsonMessageConverter.java @@ -32,7 +32,12 @@ public JsonMessageConverter(TypeRegistry typeRegistry) { } public String toJson(MessageOrBuilder message) { - return Exceptions.uncheck(() -> jsonPrinter.print(message), String.class); + if ("true".equals(System.getenv("GRPC_JSON_PRINTER_INCLUDE_ALL_DEFAULT_VALUE_FIELDS"))) { + return Exceptions.uncheck( + () -> jsonPrinter.includingDefaultValueFields().print(message), String.class); + } else { + return Exceptions.uncheck(() -> jsonPrinter.print(message), String.class); + } } @SuppressWarnings("unchecked")