From 161fbcaa2ddb2559abe7165899e6c7a865653b9b Mon Sep 17 00:00:00 2001 From: "Justin \"J.R.\" Hill" Date: Thu, 3 Aug 2023 13:48:57 -0700 Subject: [PATCH] fix(java): Update to use JsonMapper --- .../clients/java/template/libraries/native/JSON.mustache | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config/clients/java/template/libraries/native/JSON.mustache b/config/clients/java/template/libraries/native/JSON.mustache index a13bf2fd..b2940bc6 100644 --- a/config/clients/java/template/libraries/native/JSON.mustache +++ b/config/clients/java/template/libraries/native/JSON.mustache @@ -24,11 +24,12 @@ public class JSON { private ObjectMapper mapper; public JSON() { - mapper = new ObjectMapper(); + mapper = JsonMapper.builder() + .configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false) + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true) + .configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true) + .build(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true); - mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);