ObjectMapper o = new ObjectMapper();
String json = "\"5\""; // notice json string rather than json number
Integer result = o.readValue(json, Integer.class); // expect throws for wrong type
System.out.println("Hello world!");
In default configuration this does not seem to throw mismatch exception. Which of the flags should be used to prevent type coercion? For enums I found FAIL_ON_NUMBERS_AS_ENUMS, but I couldn't seem to find an equivalent for general coercion.
Ah, the databind module contains allow scalar coercion feature which solves my problem
--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jackson-user/048bd9e4-cd72-4ac3-b6ea-aee5ffeb34d9n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jackson-user/CAE9hW8T_BnZ0MVt%2BH7XX2QOAsOdTNf-dAqZwqKd9g7OTz5p7_g%40mail.gmail.com.
Yeah, i suppose i need to move there as well. I sent message here out of habit
To view this discussion visit https://groups.google.com/d/msgid/jackson-user/CALS-ipw9AAQ4Dp_H%2BeGTVLiP%2B90LAwZgRN2%3DtZaKoqSisLrSYA%40mail.gmail.com.