PropertyTypedObjectDeserializer |
This Jackson deserializer makes it possible to register field matching
regular expressions that can be matched to class names, as in the following
example:
SimpleModule deserializerModule =
new SimpleModule("PropertyTypedObjectDeserializerModule",
new Version(1, 0, 0, null, "org.apache.unomi.rest", "deserializer"));
PropertyTypedObjectDeserializer propertyTypedObjectDeserializer = new PropertyTypedObjectDeserializer(null, null);
propertyTypedObjectDeserializer.registerMapping("type=.*Condition", Condition.class);
deserializerModule.addDeserializer(Object.class, propertyTypedObjectDeserializer);
objectMapper.registerModule(deserializerModule);
In this example any JSON object that has a "type" property that matches the
".*Condition" regular expression will be parsed and mapped to a Condition class
Note that there exists a way to map properties as type identifiers in Jackson,
but this feature is very limited and requires hardcoding possible values.
|