当前位置: 首页>>代码示例>>Java>>正文


Java JsonDeserializer类代码示例

本文整理汇总了Java中org.codehaus.jackson.map.JsonDeserializer的典型用法代码示例。如果您正苦于以下问题:Java JsonDeserializer类的具体用法?Java JsonDeserializer怎么用?Java JsonDeserializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsonDeserializer类属于org.codehaus.jackson.map包,在下文中一共展示了JsonDeserializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _findRootDeserializer

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
/**
 * Method called to locate deserializer for the passed root-level value.
 */
protected JsonDeserializer<Object> _findRootDeserializer(DeserializationConfig cfg, JavaType valueType)
        throws JsonMappingException {

    // Sanity check: must have actual type...
    if (valueType == null) {
        throw new JsonMappingException("No value type configured for ObjectReader");
    }

    // First: have we already seen it?
    JsonDeserializer<Object> deser = _rootDeserializers.get(valueType);
    if (deser != null) {
        return deser;
    }

    // es-hadoop: findType with 2 args have been removed since 1.9 so this code compiles on 1.8 (which has the fallback method)
    // es-hadoop: on 1.5 only the 2 args method exists, since 1.9 only the one with 3 args hence the if

    // Nope: need to ask provider to resolve it
    deser = _provider.findTypedValueDeserializer(cfg, valueType);
    if (deser == null) { // can this happen?
        throw new JsonMappingException("Can not find a deserializer for type " + valueType);
    }
    _rootDeserializers.put(valueType, deser);
    return deser;
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:29,代码来源:BackportedObjectReader.java

示例2: BackportedJacksonMappingIterator

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected BackportedJacksonMappingIterator(JavaType type, JsonParser jp, DeserializationContext ctxt, JsonDeserializer<?> deser) {
    _type = type;
    _parser = jp;
    _context = ctxt;
    _deserializer = (JsonDeserializer<T>) deser;

    /* One more thing: if we are at START_ARRAY (but NOT root-level
     * one!), advance to next token (to allow matching END_ARRAY)
     */
    if (jp != null && jp.getCurrentToken() == JsonToken.START_ARRAY) {
        JsonStreamContext sc = jp.getParsingContext();
        // safest way to skip current token is to clear it (so we'll advance soon)
        if (!sc.inRoot()) {
            jp.clearCurrentToken();
        }
    }
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:19,代码来源:BackportedJacksonMappingIterator.java

示例3: addDiscoverableDeserializers

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
/**
 * Search for any registered JsonDeserialize instances that have been declared using the
 * ServiceLoader. Add any found to the given mapper in a 'magic' module.
 */
private static void addDiscoverableDeserializers(final ObjectMapper mapper) {

    final ServiceLoader<JsonDeserializer> loader = ServiceLoader.load(JsonDeserializer.class);
    final Iterator<JsonDeserializer> iterator = loader.iterator();
    final SimpleModule magic = new SimpleModule("magic", new Version(1, 0, 0, ""));

    while (iterator.hasNext()) {

        final JsonDeserializer<?> deserializer = iterator.next();

        try {
            final Method deserialeMethod = deserializer.getClass()
                    .getDeclaredMethod("deserialize", JsonParser.class, DeserializationContext.class);
            final Class<?> jsonType = deserialeMethod.getReturnType();
            //noinspection unchecked
            magic.addDeserializer(jsonType, (JsonDeserializer) deserializer);
        }
        catch(Exception e) {
            throw new IllegalStateException(e);
        }
    }

    mapper.registerModule(magic);
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:29,代码来源:BasicObjectMapperProvider.java

示例4: _findDeserializer

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
protected final JsonDeserializer<Object> _findDeserializer(DeserializationContext paramDeserializationContext, String paramString)
  throws IOException, JsonProcessingException
{
  JavaType localJavaType;
  synchronized (this._deserializers)
  {
    localJsonDeserializer = (JsonDeserializer)this._deserializers.get(paramString);
    if (localJsonDeserializer != null)
      break label125;
    localJavaType = this._idResolver.typeFromId(paramString);
    if (localJavaType == null)
      throw paramDeserializationContext.unknownTypeException(this._baseType, paramString);
  }
  if ((this._baseType != null) && (this._baseType.getClass() == localJavaType.getClass()))
    localJavaType = this._baseType.narrowBy(localJavaType.getRawClass());
  JsonDeserializer localJsonDeserializer = paramDeserializationContext.getDeserializerProvider().findValueDeserializer(paramDeserializationContext.getConfig(), localJavaType, this._property);
  this._deserializers.put(paramString, localJsonDeserializer);
  label125: monitorexit;
  return localJsonDeserializer;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:21,代码来源:TypeDeserializerBase.java

示例5: createCollectionLikeDeserializer

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, CollectionLikeType paramCollectionLikeType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  CollectionLikeType localCollectionLikeType1 = (CollectionLikeType)mapAbstractType(paramDeserializationConfig, paramCollectionLikeType);
  BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectClassAnnotations(localCollectionLikeType1.getRawClass());
  JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty);
  if (localJsonDeserializer1 != null)
    return localJsonDeserializer1;
  CollectionLikeType localCollectionLikeType2 = (CollectionLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localCollectionLikeType1, null);
  JavaType localJavaType = localCollectionLikeType2.getContentType();
  JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType.getValueHandler();
  TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType.getTypeHandler();
  if (localTypeDeserializer == null)
    localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType, paramBeanProperty);
  return _findCustomCollectionLikeDeserializer(localCollectionLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localTypeDeserializer, localJsonDeserializer2);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:17,代码来源:BasicDeserializerFactory.java

示例6: createEnumDeserializer

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
public JsonDeserializer<?> createEnumDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, JavaType paramJavaType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectForCreation(paramJavaType);
  JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty);
  if (localJsonDeserializer1 != null)
    return localJsonDeserializer1;
  Class localClass = paramJavaType.getRawClass();
  JsonDeserializer localJsonDeserializer2 = _findCustomEnumDeserializer(localClass, paramDeserializationConfig, localBasicBeanDescription, paramBeanProperty);
  if (localJsonDeserializer2 != null)
    return localJsonDeserializer2;
  Iterator localIterator = localBasicBeanDescription.getFactoryMethods().iterator();
  while (localIterator.hasNext())
  {
    AnnotatedMethod localAnnotatedMethod = (AnnotatedMethod)localIterator.next();
    if (!paramDeserializationConfig.getAnnotationIntrospector().hasCreatorAnnotation(localAnnotatedMethod))
      continue;
    if ((localAnnotatedMethod.getParameterCount() == 1) && (localAnnotatedMethod.getRawType().isAssignableFrom(localClass)))
      return EnumDeserializer.deserializerForCreator(paramDeserializationConfig, localClass, localAnnotatedMethod);
    throw new IllegalArgumentException("Unsuitable method (" + localAnnotatedMethod + ") decorated with @JsonCreator (for Enum type " + localClass.getName() + ")");
  }
  return new EnumDeserializer(constructEnumResolver(localClass, paramDeserializationConfig));
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:24,代码来源:BasicDeserializerFactory.java

示例7: createMapLikeDeserializer

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
public JsonDeserializer<?> createMapLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, MapLikeType paramMapLikeType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  MapLikeType localMapLikeType1 = (MapLikeType)mapAbstractType(paramDeserializationConfig, paramMapLikeType);
  BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectForCreation(localMapLikeType1);
  JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty);
  if (localJsonDeserializer1 != null)
    return localJsonDeserializer1;
  MapLikeType localMapLikeType2 = (MapLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localMapLikeType1, null);
  JavaType localJavaType1 = localMapLikeType2.getKeyType();
  JavaType localJavaType2 = localMapLikeType2.getContentType();
  JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType2.getValueHandler();
  KeyDeserializer localKeyDeserializer = (KeyDeserializer)localJavaType1.getValueHandler();
  if (localKeyDeserializer == null)
    localKeyDeserializer = paramDeserializerProvider.findKeyDeserializer(paramDeserializationConfig, localJavaType1, paramBeanProperty);
  TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType2.getTypeHandler();
  if (localTypeDeserializer == null)
    localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType2, paramBeanProperty);
  return _findCustomMapLikeDeserializer(localMapLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localKeyDeserializer, localTypeDeserializer, localJsonDeserializer2);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:21,代码来源:BasicDeserializerFactory.java

示例8: findStdBeanDeserializer

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
protected JsonDeserializer<Object> findStdBeanDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, JavaType paramJavaType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  JsonDeserializer localJsonDeserializer1 = (JsonDeserializer)_simpleDeserializers.get(paramJavaType);
  if (localJsonDeserializer1 != null)
    return localJsonDeserializer1;
  if (AtomicReference.class.isAssignableFrom(paramJavaType.getRawClass()))
  {
    JavaType[] arrayOfJavaType = paramDeserializationConfig.getTypeFactory().findTypeParameters(paramJavaType, AtomicReference.class);
    if ((arrayOfJavaType == null) || (arrayOfJavaType.length < 1));
    for (JavaType localJavaType = TypeFactory.unknownType(); ; localJavaType = arrayOfJavaType[0])
      return new StdDeserializer.AtomicReferenceDeserializer(localJavaType, paramBeanProperty);
  }
  JsonDeserializer localJsonDeserializer2 = this.optionalHandlers.findDeserializer(paramJavaType, paramDeserializationConfig, paramDeserializerProvider);
  if (localJsonDeserializer2 != null)
    return localJsonDeserializer2;
  return null;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:19,代码来源:BasicDeserializerFactory.java

示例9: handlePolymorphic

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
protected Object handlePolymorphic(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Object paramObject, TokenBuffer paramTokenBuffer)
  throws IOException, JsonProcessingException
{
  JsonDeserializer localJsonDeserializer = _findSubclassDeserializer(paramDeserializationContext, paramObject, paramTokenBuffer);
  if (localJsonDeserializer != null)
  {
    if (paramTokenBuffer != null)
    {
      paramTokenBuffer.writeEndObject();
      JsonParser localJsonParser = paramTokenBuffer.asParser();
      localJsonParser.nextToken();
      paramObject = localJsonDeserializer.deserialize(localJsonParser, paramDeserializationContext, paramObject);
    }
    if (paramJsonParser != null)
      paramObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext, paramObject);
    return paramObject;
  }
  if (paramTokenBuffer != null)
    paramObject = handleUnknownProperties(paramDeserializationContext, paramObject, paramTokenBuffer);
  if (paramJsonParser != null)
    paramObject = deserialize(paramJsonParser, paramDeserializationContext, paramObject);
  return paramObject;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:24,代码来源:BeanDeserializer.java

示例10: findValueDeserializer

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
public JsonDeserializer<Object> findValueDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  JsonDeserializer localJsonDeserializer1 = _findCachedDeserializer(paramJavaType);
  if (localJsonDeserializer1 != null)
  {
    if ((localJsonDeserializer1 instanceof ContextualDeserializer))
      localJsonDeserializer1 = ((ContextualDeserializer)localJsonDeserializer1).createContextual(paramDeserializationConfig, paramBeanProperty);
    return localJsonDeserializer1;
  }
  JsonDeserializer localJsonDeserializer2 = _createAndCacheValueDeserializer(paramDeserializationConfig, paramJavaType, paramBeanProperty);
  if (localJsonDeserializer2 == null)
    localJsonDeserializer2 = _handleUnknownValueDeserializer(paramJavaType);
  if ((localJsonDeserializer2 instanceof ContextualDeserializer))
    localJsonDeserializer2 = ((ContextualDeserializer)localJsonDeserializer2).createContextual(paramDeserializationConfig, paramBeanProperty);
  return localJsonDeserializer2;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:18,代码来源:StdDeserializerProvider.java

示例11: hasValueDeserializerFor

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
public boolean hasValueDeserializerFor(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType)
{
  Object localObject = _findCachedDeserializer(paramJavaType);
  if (localObject == null);
  try
  {
    JsonDeserializer localJsonDeserializer = _createAndCacheValueDeserializer(paramDeserializationConfig, paramJavaType, null);
    localObject = localJsonDeserializer;
    int i = 0;
    if (localObject != null)
      i = 1;
    return i;
  }
  catch (Exception localException)
  {
  }
  return false;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:19,代码来源:StdDeserializerProvider.java

示例12: handleNonArray

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
private final Collection<Object> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<Object> paramCollection)
  throws IOException, JsonProcessingException
{
  if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY))
    throw paramDeserializationContext.mappingException(this._collectionType.getRawClass());
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer;
  Object localObject;
  if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL)
    localObject = null;
  while (true)
  {
    paramCollection.add(localObject);
    return paramCollection;
    if (localTypeDeserializer == null)
    {
      localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
      continue;
    }
    localObject = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer);
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:23,代码来源:CollectionDeserializer.java

示例13: deserializeUsingCustom

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
private Collection<String> deserializeUsingCustom(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection)
  throws IOException, JsonProcessingException
{
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  JsonToken localJsonToken = paramJsonParser.nextToken();
  if (localJsonToken != JsonToken.END_ARRAY)
  {
    if (localJsonToken == JsonToken.VALUE_NULL);
    for (Object localObject = null; ; localObject = (String)localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext))
    {
      paramCollection.add(localObject);
      break;
    }
  }
  return (Collection<String>)paramCollection;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:17,代码来源:StringCollectionDeserializer.java

示例14: handleNonArray

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
private final Collection<String> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection)
  throws IOException, JsonProcessingException
{
  if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY))
    throw paramDeserializationContext.mappingException(this._collectionType.getRawClass());
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL)
  {
    localObject = null;
    paramCollection.add(localObject);
    return paramCollection;
  }
  if (localJsonDeserializer == null);
  for (Object localObject = paramJsonParser.getText(); ; localObject = (String)localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext))
    break;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:17,代码来源:StringCollectionDeserializer.java

示例15: buildBeanDeserializer

import org.codehaus.jackson.map.JsonDeserializer; //导入依赖的package包/类
public JsonDeserializer<Object> buildBeanDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BasicBeanDescription paramBasicBeanDescription, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  BeanDeserializerBuilder localBeanDeserializerBuilder = constructBeanDeserializerBuilder(paramBasicBeanDescription);
  localBeanDeserializerBuilder.setCreators(findDeserializerCreators(paramDeserializationConfig, paramBasicBeanDescription));
  addBeanProps(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder);
  addReferenceProperties(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder);
  if (this._factoryConfig.hasDeserializerModifiers())
  {
    Iterator localIterator2 = this._factoryConfig.deserializerModifiers().iterator();
    while (localIterator2.hasNext())
      localBeanDeserializerBuilder = ((BeanDeserializerModifier)localIterator2.next()).updateBuilder(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder);
  }
  JsonDeserializer localJsonDeserializer = localBeanDeserializerBuilder.build(paramBeanProperty);
  if (this._factoryConfig.hasDeserializerModifiers())
  {
    Iterator localIterator1 = this._factoryConfig.deserializerModifiers().iterator();
    while (localIterator1.hasNext())
      localJsonDeserializer = ((BeanDeserializerModifier)localIterator1.next()).modifyDeserializer(paramDeserializationConfig, paramBasicBeanDescription, localJsonDeserializer);
  }
  return localJsonDeserializer;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:23,代码来源:BeanDeserializerFactory.java


注:本文中的org.codehaus.jackson.map.JsonDeserializer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。