I am serializing and deserializing following domain object to JSON using Jackson 1.8.3
public class Node {
private String key;
private Object value;
private List<Node> children = new ArrayList<Node>();
/* getters and setters omitted for brevity */
}
Object is then serialized and deserialized using following code
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(destination, rootNode);
And then later deserialized with
mapper.readValue(destination, Node.class);
The original values of the object are either Strings, Doubles, Longs or Booleans. However, during serialization and deserialization Jackson transforms Long values (such as 4) to Integers.
How can I "force" Jackson to deserialize numeric non-decimal values to Long instead of Integer?
I've used something like the below to work around this problem.