Convert String to Integer using FasterXML Jackson Convert String to Integer using FasterXML Jackson json json

Convert String to Integer using FasterXML Jackson


Jackson actually handles coercion, so that if property has type int or java.lang.Integer, it will parse JSON Strings, not just use JSON Numbers.Reverse is possible as well, using @JsonFormat(shape=Shape.STRING) for numeric fields.


Since you don't always have the same format, the best way to do it is to retrieve it as a string and parse it :

int detailId = (int) Float.parseFloat(node.path("details").asText());