use of com.fasterxml.jackson.databind.JavaType in project Gaffer by gchq.
the class CloseableIterableDeserializer method createContextual.
@Override
public JsonDeserializer<?> createContextual(final DeserializationContext deserializationContext, final BeanProperty property) throws JsonMappingException {
final JavaType valueType = deserializationContext.getContextualType().containedType(0);
final CloseableIterableDeserializer deserializer = new CloseableIterableDeserializer();
deserializer.valueType = valueType;
return deserializer;
}
use of com.fasterxml.jackson.databind.JavaType in project Fast-Android-Networking by amitshekhariitbhu.
the class JacksonParserFactory method responseBodyParser.
@Override
public Parser<ResponseBody, ?> responseBodyParser(Type type) {
JavaType javaType = mapper.getTypeFactory().constructType(type);
ObjectReader reader = mapper.readerFor(javaType);
return new JacksonResponseBodyParser<>(reader);
}
use of com.fasterxml.jackson.databind.JavaType in project Fast-Android-Networking by amitshekhariitbhu.
the class JacksonParserFactory method getObject.
@Override
public Object getObject(String string, Type type) {
try {
JavaType javaType = mapper.getTypeFactory().constructType(type);
ObjectReader objectReader = mapper.readerFor(javaType);
return objectReader.readValue(string);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.fasterxml.jackson.databind.JavaType in project spring-framework by spring-projects.
the class AbstractJackson2HttpMessageConverter method canRead.
@Override
public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) {
if (!canRead(mediaType)) {
return false;
}
JavaType javaType = getJavaType(type, contextClass);
if (!logger.isWarnEnabled()) {
return this.objectMapper.canDeserialize(javaType);
}
AtomicReference<Throwable> causeRef = new AtomicReference<>();
if (this.objectMapper.canDeserialize(javaType, causeRef)) {
return true;
}
logWarningIfNecessary(javaType, causeRef.get());
return false;
}
use of com.fasterxml.jackson.databind.JavaType in project jackson-databind by FasterXML.
the class UntypedObjectDeserializer method resolve.
/*
/**********************************************************
/* Initialization
/**********************************************************
*/
/**
* We need to implement this method to properly find things to delegate
* to: it can not be done earlier since delegated deserializers almost
* certainly require access to this instance (at least "List" and "Map" ones)
*/
@SuppressWarnings("unchecked")
@Override
public void resolve(DeserializationContext ctxt) throws JsonMappingException {
JavaType obType = ctxt.constructType(Object.class);
JavaType stringType = ctxt.constructType(String.class);
TypeFactory tf = ctxt.getTypeFactory();
// So: first find possible custom instances
if (_listType == null) {
_listDeserializer = _clearIfStdImpl(_findCustomDeser(ctxt, tf.constructCollectionType(List.class, obType)));
} else {
// NOTE: if non-default List type, always consider to be non-standard deser
_listDeserializer = _findCustomDeser(ctxt, _listType);
}
if (_mapType == null) {
_mapDeserializer = _clearIfStdImpl(_findCustomDeser(ctxt, tf.constructMapType(Map.class, stringType, obType)));
} else {
// NOTE: if non-default Map type, always consider to be non-standard deser
_mapDeserializer = _findCustomDeser(ctxt, _mapType);
}
_stringDeserializer = _clearIfStdImpl(_findCustomDeser(ctxt, stringType));
_numberDeserializer = _clearIfStdImpl(_findCustomDeser(ctxt, tf.constructType(Number.class)));
// and then do bogus contextualization, in case custom ones need to resolve dependencies of
// their own
JavaType unknown = TypeFactory.unknownType();
_mapDeserializer = (JsonDeserializer<Object>) ctxt.handleSecondaryContextualization(_mapDeserializer, null, unknown);
_listDeserializer = (JsonDeserializer<Object>) ctxt.handleSecondaryContextualization(_listDeserializer, null, unknown);
_stringDeserializer = (JsonDeserializer<Object>) ctxt.handleSecondaryContextualization(_stringDeserializer, null, unknown);
_numberDeserializer = (JsonDeserializer<Object>) ctxt.handleSecondaryContextualization(_numberDeserializer, null, unknown);
}
Aggregations