@Test @SneakyThrows void defaultMapperMapsBigDecimalAsPlain() { ObjectMapper mapper = factory.defaultMapper(); Map<String, BigDecimal> test = ImmutableMap.of("v", new BigDecimal("1E+1")); String value = mapper.writer().writeValueAsString(test); assertThat(value).isEqualTo("{\"v\":10}"); }
ObjectMapper defaultMapper() { SimpleModule module = new SimpleModule(); module.addSerializer(new BigDecimalSerializer()); return new ObjectMapper(new JsonFactory()) .setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS, false) .configure(DeserializationFeature.ACCEPT_FLOAT_AS_INT, true) .configure(DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES, false) .registerModule(module); }
ConfigFactory { ObjectMapper defaultMapper() { SimpleModule module = new SimpleModule(); module.addSerializer(new BigDecimalSerializer()); return new ObjectMapper(new JsonFactory()) .setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS, false) .configure(DeserializationFeature.ACCEPT_FLOAT_AS_INT, true) .configure(DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES, false) .registerModule(module); } }
ConfigFactory { ObjectMapper defaultMapper() { SimpleModule module = new SimpleModule(); module.addSerializer(new BigDecimalSerializer()); return new ObjectMapper(new JsonFactory()) .setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS, false) .configure(DeserializationFeature.ACCEPT_FLOAT_AS_INT, true) .configure(DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES, false) .registerModule(module); }  }
ConfigFactory { ObjectMapper defaultMapper() { SimpleModule module = new SimpleModule(); module.addSerializer(new BigDecimalSerializer()); return new ObjectMapper(new JsonFactory()) .setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS, false) .configure(DeserializationFeature.ACCEPT_FLOAT_AS_INT, true) .configure(DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES, false) .registerModule(module); }   }
ConfigFactory { ObjectMapper defaultMapper() { SimpleModule module = new SimpleModule(); module.addSerializer(new BigDecimalSerializer()); return new ObjectMapper(new JsonFactory()) .setPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CAMEL_CASE) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS, false) .configure(DeserializationFeature.ACCEPT_FLOAT_AS_INT, true) .configure(DeserializationFeature.FAIL_ON_NULL_CREATOR_PROPERTIES, false) .registerModule(module); }    }