public class TestJacksonColor {
public static void main(String [] args) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
Color black = new Color(0, 0, 0);
String json = objectMapper.writeValueAsString(black);
Color backToObject = objectMapper.readValue(json, Color.class);
}
}
The code attempts to take an java.awt.color class serialize it using jackson objectmapper. Take the resulting json string and deserialize it back to an java.awt.color class. However when doing the deserialization the following error occurs.
Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class java.awt.Color]: can not instantiate from JSON object