2

I have a POST endpoint receiving json in the request body and is mapped to Map<String, Object>.

The value can be of any string format, I am OK for Spring to auto convert "true" or "false" to Boolean, "123" to Integer. But I do not like it to convert "123.456" to Double, I want it to leave it as is (String).

Is there any way (preferably config in application.yml) to selectively stop Spring from auto converting number string in json to Double only?

user1589188
  • 5,316
  • 17
  • 67
  • 130
  • What do you mean by "stop" ? Ignore/big decimal/String/...? (...`@JsonIgnore`/`DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS`/https://www.baeldung.com/jackson-deserialization) – xerx593 Nov 10 '22 at 09:26
  • @xerx593 I mean I want it to leave it as is (`String`). – user1589188 Nov 10 '22 at 09:39
  • Maybe this can help. https://stackoverflow.com/questions/67695180/is-it-possible-to-customize-objectmapper-for-single-spring-rest-endpoint – Gergo Nov 10 '22 at 09:58

0 Answers0