Java Code Examples for org.codehaus.jackson.map.DeserializationConfig#set()
The following examples show how to use
org.codehaus.jackson.map.DeserializationConfig#set() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertyJsonSerializer.java From helix with Apache License 2.0 | 6 votes |
@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; }
Example 2
Source File: JacksonPayloadSerializer.java From helix with Apache License 2.0 | 6 votes |
@Override public <T> T deserialize(final Class<T> clazz, final byte[] bytes) { if (bytes == null || bytes.length == 0) { 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 { T payload = mapper.readValue(bais, clazz); return payload; } catch (Exception e) { logger.error("Exception during deserialization of payload bytes: " + new String(bytes), e); return null; } }