use of org.codehaus.jackson.map.DeserializationConfig in project ANNIS by korpling.
the class AnnisRunner method doAnnotations.
public void doAnnotations(String doListValues) {
boolean listValues = "values".equals(doListValues);
List<AnnisAttribute> annotations = queryDao.listAnnotations(getCorpusList(), listValues, true);
try {
ObjectMapper om = new ObjectMapper();
AnnotationIntrospector ai = new JaxbAnnotationIntrospector();
DeserializationConfig config = om.getDeserializationConfig().withAnnotationIntrospector(ai);
om.setDeserializationConfig(config);
om.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
System.out.println(om.writeValueAsString(annotations));
} catch (IOException ex) {
log.error("problems with writing result", ex);
}
}
use of org.codehaus.jackson.map.DeserializationConfig in project ovirt-engine by oVirt.
the class V3CustomObjectMapper method addSerializationConfig.
protected V3CustomObjectMapper addSerializationConfig() {
// We need the instrospector that takes into account the JAXB annotations,
// both for the serializer and for the deserializer:
JaxbAnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
// Configure the serializer:
SerializationConfig serCfg = getSerializationConfig().withAnnotationIntrospector(introspector);
setSerializationConfig(serCfg);
// Configure the deserializer:
DeserializationConfig deserCfg = getDeserializationConfig().withAnnotationIntrospector(introspector);
setDeserializationConfig(deserCfg);
return this;
}
use of org.codehaus.jackson.map.DeserializationConfig in project ovirt-engine by oVirt.
the class CustomObjectMapper method addSerializationConfig.
protected CustomObjectMapper addSerializationConfig() {
// We need the instrospector that takes into account the JAXB annotations,
// both for the serializer and for the deserializer:
JaxbAnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
// Configure the serializer:
SerializationConfig serCfg = getSerializationConfig().withAnnotationIntrospector(introspector);
setSerializationConfig(serCfg);
// Configure the deserializer:
DeserializationConfig deserCfg = getDeserializationConfig().withAnnotationIntrospector(introspector);
setDeserializationConfig(deserCfg);
return this;
}
use of org.codehaus.jackson.map.DeserializationConfig in project helix by apache.
the class PropertyJsonSerializer method deserialize.
@Override
public T deserialize(byte[] bytes) throws PropertyStoreException {
ObjectMapper mapper = new ObjectMapper();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
DeserializationConfig deserializationConfig = mapper.getDeserializationConfig();
deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, true);
deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, true);
deserializationConfig.set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);
try {
T value = mapper.readValue(bais, _clazz);
return value;
} catch (Exception e) {
LOG.error("Error during deserialization of bytes: " + new String(bytes), e);
}
return null;
}
use of org.codehaus.jackson.map.DeserializationConfig in project helix by apache.
the class ZNRecordSerializer method deserialize.
@Override
public Object deserialize(byte[] bytes) {
if (bytes == null || bytes.length == 0) {
// reading a parent/null node
return null;
}
ObjectMapper mapper = new ObjectMapper();
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
DeserializationConfig deserializationConfig = mapper.getDeserializationConfig();
deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, true);
deserializationConfig.set(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, true);
deserializationConfig.set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);
try {
// decompress the data if its already compressed
if (GZipCompressionUtil.isCompressed(bytes)) {
byte[] uncompressedBytes = GZipCompressionUtil.uncompress(bais);
bais = new ByteArrayInputStream(uncompressedBytes);
}
ZNRecord zn = mapper.readValue(bais, ZNRecord.class);
return zn;
} catch (Exception e) {
logger.error("Exception during deserialization of bytes: " + new String(bytes), e);
return null;
}
}
Aggregations