How to enable strict type parsing for jackson?
问题 Jackson 1.9.9 is somewhat inconsistent in what it parses into scalar values (bool, int, string). Any array or object type fails but you can put any scalar type into a string. For bool 0 and not 0 are mapped to false/true. int attributes accept only numbers. public class Foo { public String s; public boolean b; public int i; } ObjectMapper mapper = new ObjectMapper(); System.out.println(mapper.readValue("{\"s\":\"abc\"}", Foo.class).s); // "abc" System.out.println(mapper.readValue("{\"s\":true