當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonDeserializer.deserializeWithType方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.JsonDeserializer.deserializeWithType方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonDeserializer.deserializeWithType方法的具體用法?Java JsonDeserializer.deserializeWithType怎麽用?Java JsonDeserializer.deserializeWithType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.databind.JsonDeserializer的用法示例。


在下文中一共展示了JsonDeserializer.deserializeWithType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: _deserializeFromSingleValue

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
@Override
protected T _deserializeFromSingleValue(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    JsonDeserializer<?> valueDes = _valueDeserializer;
    final TypeDeserializer typeDeser = _typeDeserializerForValue;
    JsonToken t = jp.getCurrentToken();

    Object value;

    if (t == JsonToken.VALUE_NULL) {
        value = null;
    } else if (typeDeser == null) {
        value = valueDes.deserialize(jp, ctxt);
    } else {
        value = valueDes.deserializeWithType(jp, ctxt, typeDeser);
    }
    @SuppressWarnings("unchecked")
    T result = (T) Sequences.sequence(value);
    return result;
}
 
開發者ID:blomqvie,項目名稱:android-rxjava-training,代碼行數:21,代碼來源:SequenceDeserializer.java

示例2: deserialize

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
public Collection<Object> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<Object> paramCollection)
{
  if (!paramJsonParser.isExpectedStartArrayToken())
    return handleNonArray(paramJsonParser, paramDeserializationContext, paramCollection);
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer;
  while (true)
  {
    JsonToken localJsonToken = paramJsonParser.nextToken();
    if (localJsonToken == JsonToken.END_ARRAY)
      break;
    Object localObject;
    if (localJsonToken == JsonToken.VALUE_NULL)
      localObject = null;
    else if (localTypeDeserializer == null)
      localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
    else
      localObject = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer);
    paramCollection.add(localObject);
  }
  return paramCollection;
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:23,代碼來源:CollectionDeserializer.java

示例3: handleNonArray

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
protected final Collection<Object> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<Object> paramCollection)
{
  if (!paramDeserializationContext.isEnabled(DeserializationFeature.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;
  else if (localTypeDeserializer == null)
    localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
  else
    localObject = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer);
  paramCollection.add(localObject);
  return paramCollection;
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:17,代碼來源:CollectionDeserializer.java

示例4: _deserializeEntries

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected T _deserializeEntries(JsonParser jp, DeserializationContext ctxt) throws IOException {
    final KeyDeserializer keyDes = keyDeserializer;
    final JsonDeserializer<?> valueDes = valueDeserializer;
    final TypeDeserializer typeDeser = typeDeserializerForValue;

    MapF<Object, Object> map = newInstance();

    for (; jp.getCurrentToken() == JsonToken.FIELD_NAME; jp.nextToken()) {
        String fieldName = jp.getCurrentName();
        Object key = (keyDes == null) ? fieldName : keyDes.deserializeKey(fieldName, ctxt);
        JsonToken t = jp.nextToken();
        Object value;
        if (t == JsonToken.VALUE_NULL) {
            value = null;
        } else if (typeDeser == null) {
            value = valueDes.deserialize(jp, ctxt);
        } else {
            value = valueDes.deserializeWithType(jp, ctxt, typeDeser);
        }
        map.put(key, value);
    }
    return (T) map.unmodifiable();
}
 
開發者ID:v1ctor,項目名稱:jackson-datatype-bolts,代碼行數:25,代碼來源:MapDeserializer.java

示例5: _deserializeContents

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected T _deserializeContents(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonDeserializer<?> valueDes = valueDeserializer;
    JsonToken t;
    final TypeDeserializer typeDeser = typeDeserializerForValue;
    CollectionF<Object> collection = newInstance();

    while ((t = jp.nextToken()) != JsonToken.END_ARRAY) {
        Object value;

        if (t == JsonToken.VALUE_NULL) {
            value = valueDes.getNullValue();
        } else if (typeDeser == null) {
            value = valueDes.deserialize(jp, ctxt);
        } else {
            value = valueDes.deserializeWithType(jp, ctxt, typeDeser);
        }
        collection.add(value);
    }
    return (T) collection.unmodifiable();
}
 
開發者ID:v1ctor,項目名稱:jackson-datatype-bolts,代碼行數:22,代碼來源:CollectionDeserializer.java

示例6: _deserializeSingle

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected T _deserializeSingle(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonDeserializer<?> valueDes = valueDeserializer;
    final TypeDeserializer typeDeser = typeDeserializerForValue;
    CollectionF<Object> collection = newInstance();

    Object value;

    if (jp.getCurrentToken() == JsonToken.VALUE_NULL) {
        value = valueDes.getNullValue();
    } else if (typeDeser == null) {
        value = valueDes.deserialize(jp, ctxt);
    } else {
        value = valueDes.deserializeWithType(jp, ctxt, typeDeser);
    }
    collection.add(value);
    return (T) collection.unmodifiable();
}
 
開發者ID:v1ctor,項目名稱:jackson-datatype-bolts,代碼行數:19,代碼來源:CollectionDeserializer.java

示例7: _deserializeContents

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
@Override
protected T _deserializeContents(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    JsonDeserializer<?> valueDes = _valueDeserializer;
    JsonToken t;
    final TypeDeserializer typeDeser = _typeDeserializerForValue;
    // No way to pass actual type parameter; but does not matter, just
    // compiler-time fluff:
    Sequence<Object> sequence = Sequences.sequence();

    while ((t = jp.nextToken()) != JsonToken.END_ARRAY) {
        Object value;

        if (t == JsonToken.VALUE_NULL) {
            value = null;
        } else if (typeDeser == null) {
            value = valueDes.deserialize(jp, ctxt);
        } else {
            value = valueDes.deserializeWithType(jp, ctxt, typeDeser);
        }
        sequence = sequence.append(value);
    }
    // No class outside of the package will be able to subclass us,
    // and we provide the proper builder for the subclasses we implement.
    @SuppressWarnings("unchecked")
    T collection = (T) sequence;
    return collection;
}
 
開發者ID:blomqvie,項目名稱:android-rxjava-training,代碼行數:29,代碼來源:SequenceDeserializer.java

示例8: _readAndBind

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
protected final void _readAndBind(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Map<Object, Object> paramMap)
{
  JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
  JsonToken localJsonToken2 = localJsonToken1;
  if (localJsonToken1 == JsonToken.START_OBJECT)
    localJsonToken2 = paramJsonParser.nextToken();
  KeyDeserializer localKeyDeserializer = this._keyDeserializer;
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer;
  while (localJsonToken2 == JsonToken.FIELD_NAME)
  {
    String str = paramJsonParser.getCurrentName();
    Object localObject1 = localKeyDeserializer.deserializeKey(str, paramDeserializationContext);
    JsonToken localJsonToken3 = paramJsonParser.nextToken();
    if ((this._ignorableProperties != null) && (this._ignorableProperties.contains(str)))
    {
      paramJsonParser.skipChildren();
    }
    else
    {
      Object localObject2;
      if (localJsonToken3 == JsonToken.VALUE_NULL)
        localObject2 = null;
      else if (localTypeDeserializer == null)
        localObject2 = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
      else
        localObject2 = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer);
      paramMap.put(localObject1, localObject2);
    }
    localJsonToken2 = paramJsonParser.nextToken();
  }
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:33,代碼來源:MapDeserializer.java

示例9: _readAndBindStringMap

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
protected final void _readAndBindStringMap(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Map<Object, Object> paramMap)
{
  JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
  JsonToken localJsonToken2 = localJsonToken1;
  if (localJsonToken1 == JsonToken.START_OBJECT)
    localJsonToken2 = paramJsonParser.nextToken();
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer;
  while (localJsonToken2 == JsonToken.FIELD_NAME)
  {
    String str = paramJsonParser.getCurrentName();
    JsonToken localJsonToken3 = paramJsonParser.nextToken();
    if ((this._ignorableProperties != null) && (this._ignorableProperties.contains(str)))
    {
      paramJsonParser.skipChildren();
    }
    else
    {
      Object localObject;
      if (localJsonToken3 == JsonToken.VALUE_NULL)
        localObject = null;
      else if (localTypeDeserializer == null)
        localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
      else
        localObject = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer);
      paramMap.put(str, localObject);
    }
    localJsonToken2 = paramJsonParser.nextToken();
  }
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:31,代碼來源:MapDeserializer.java

示例10: deserialize

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
public Collection<Object> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<Object> paramCollection)
{
  if (!paramJsonParser.isExpectedStartArrayToken())
    return handleNonArray(paramJsonParser, paramDeserializationContext, new ArrayBlockingQueue(1));
  ArrayList localArrayList = new ArrayList();
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer;
  while (true)
  {
    JsonToken localJsonToken = paramJsonParser.nextToken();
    if (localJsonToken == JsonToken.END_ARRAY)
      break;
    Object localObject;
    if (localJsonToken == JsonToken.VALUE_NULL)
      localObject = null;
    else if (localTypeDeserializer == null)
      localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
    else
      localObject = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer);
    localArrayList.add(localObject);
  }
  if (paramCollection != null)
  {
    paramCollection.addAll(localArrayList);
    return paramCollection;
  }
  return new ArrayBlockingQueue(localArrayList.size(), false, localArrayList);
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:29,代碼來源:ArrayBlockingQueueDeserializer.java

示例11: deserializeElement

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
private Object deserializeElement(JsonDeserializer<?> deserializer, TypeDeserializer typeDeserializer,
        JsonParser parser, DeserializationContext context) throws IOException
{
    if (parser.getCurrentToken() == JsonToken.VALUE_NULL) {
        return deserializer.getNullValue();
    } else if (typeDeserializer == null) {
        return deserializer.deserialize(parser, context);
    }
    return deserializer.deserializeWithType(parser, context, typeDeserializer);
}
 
開發者ID:v1ctor,項目名稱:jackson-datatype-bolts,代碼行數:11,代碼來源:Tuple2Deserializer.java

示例12: deserialize

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
@Override
public Collection<Object> deserialize(JsonParser p, DeserializationContext ctxt,
                                      Collection<Object> result)
        throws IOException {
    // Ok: must point to START_ARRAY (or equivalent)
    if (!p.isExpectedStartArrayToken()) {
        return result;
    }
    // [databind#631]: Assign current value, to be accessible by custom serializers
    p.setCurrentValue(result);

    JsonDeserializer<Object> valueDes = _valueDeserializer;
    final TypeDeserializer typeDeser = _valueTypeDeserializer;
    CollectionReferringAccumulator referringAccumulator =
            (valueDes.getObjectIdReader() == null) ? null :
                    new CollectionReferringAccumulator(_containerType.getContentType().getRawClass(), result);

    JsonToken t;
    while ((t = p.nextToken()) != JsonToken.END_ARRAY) {
        try {
            Object value;
            if (t == JsonToken.VALUE_NULL) {
                if (_skipNullValues) {
                    continue;
                }
                value = _nullProvider.getNullValue(ctxt);
            } else if (typeDeser == null) {
                value = valueDes.deserialize(p, ctxt);
            } else {
                value = valueDes.deserializeWithType(p, ctxt, typeDeser);
            }
            if (referringAccumulator != null) {
                referringAccumulator.add(value);
            } else {
                result.add(value);
            }
        } catch (UnresolvedForwardReference reference) {
            if (referringAccumulator == null) {
                throw JsonMappingException
                        .from(p, "Unresolved forward reference but no identity info", reference);
            }
            ReadableObjectId.Referring ref = referringAccumulator.handleUnresolvedReference(reference);
            reference.getRoid().appendReferring(ref);
        } catch (Exception e) {
            boolean wrap = (ctxt == null) || ctxt.isEnabled(DeserializationFeature.WRAP_EXCEPTIONS);
            if (!wrap) {
                ClassUtil.throwIfRTE(e);
            }
            throw JsonMappingException.wrapWithPath(e, result, result.size());
        }
    }
    return result;
}
 
開發者ID:allure-framework,項目名稱:allure2,代碼行數:54,代碼來源:ListDeserializer.java

示例13: _deserializeUsingCreator

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
public Map<Object, Object> _deserializeUsingCreator(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
{
  PropertyBasedCreator localPropertyBasedCreator = this._propertyBasedCreator;
  PropertyValueBuffer localPropertyValueBuffer = localPropertyBasedCreator.startBuilding(paramJsonParser, paramDeserializationContext, null);
  JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
  JsonToken localJsonToken2 = localJsonToken1;
  if (localJsonToken1 == JsonToken.START_OBJECT)
    localJsonToken2 = paramJsonParser.nextToken();
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer;
  while (localJsonToken2 == JsonToken.FIELD_NAME)
  {
    String str1 = paramJsonParser.getCurrentName();
    JsonToken localJsonToken3 = paramJsonParser.nextToken();
    if ((this._ignorableProperties != null) && (this._ignorableProperties.contains(str1)))
    {
      paramJsonParser.skipChildren();
    }
    else
    {
      SettableBeanProperty localSettableBeanProperty = localPropertyBasedCreator.findCreatorProperty(str1);
      if (localSettableBeanProperty != null)
      {
        Object localObject3 = localSettableBeanProperty.deserialize(paramJsonParser, paramDeserializationContext);
        if (localPropertyValueBuffer.assignParameter(localSettableBeanProperty.getCreatorIndex(), localObject3))
        {
          paramJsonParser.nextToken();
          Map localMap2;
          try
          {
            localMap2 = (Map)localPropertyBasedCreator.build(paramDeserializationContext, localPropertyValueBuffer);
          }
          catch (Exception localException2)
          {
            wrapAndThrow(localException2, this._mapType.getRawClass());
            return null;
          }
          _readAndBind(paramJsonParser, paramDeserializationContext, localMap2);
          return localMap2;
        }
      }
      else
      {
        String str2 = paramJsonParser.getCurrentName();
        Object localObject1 = this._keyDeserializer.deserializeKey(str2, paramDeserializationContext);
        Object localObject2;
        if (localJsonToken3 == JsonToken.VALUE_NULL)
          localObject2 = null;
        else if (localTypeDeserializer == null)
          localObject2 = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
        else
          localObject2 = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer);
        localPropertyValueBuffer.bufferMapProperty(localObject1, localObject2);
      }
    }
    localJsonToken2 = paramJsonParser.nextToken();
  }
  try
  {
    Map localMap1 = (Map)localPropertyBasedCreator.build(paramDeserializationContext, localPropertyValueBuffer);
    return localMap1;
  }
  catch (Exception localException1)
  {
    wrapAndThrow(localException1, this._mapType.getRawClass());
  }
  return null;
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:69,代碼來源:MapDeserializer.java

示例14: deserialize

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
public EnumMap<?, ?> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
{
  if (paramJsonParser.getCurrentToken() != JsonToken.START_OBJECT)
    throw paramDeserializationContext.mappingException(EnumMap.class);
  EnumMap localEnumMap = constructMap();
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer;
  while (paramJsonParser.nextToken() != JsonToken.END_OBJECT)
  {
    Enum localEnum = (Enum)this._keyDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
    if (localEnum == null)
    {
      if (!paramDeserializationContext.isEnabled(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL))
      {
        String str = null;
        try
        {
          if (paramJsonParser.hasCurrentToken())
            str = paramJsonParser.getText();
        }
        catch (Exception localException)
        {
        }
        throw paramDeserializationContext.weirdStringException(str, this._enumClass, "value not one of declared Enum instance names");
      }
      paramJsonParser.nextToken();
      paramJsonParser.skipChildren();
    }
    else
    {
      Object localObject;
      if (paramJsonParser.nextToken() == JsonToken.VALUE_NULL)
        localObject = null;
      else if (localTypeDeserializer == null)
        localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
      else
        localObject = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer);
      localEnumMap.put(localEnum, localObject);
    }
  }
  return localEnumMap;
}
 
開發者ID:mmmsplay10,項目名稱:QuizUpWinner,代碼行數:43,代碼來源:EnumMapDeserializer.java

示例15: findMapDeserializer

import com.fasterxml.jackson.databind.JsonDeserializer; //導入方法依賴的package包/類
@Override
public JsonDeserializer<?> findMapDeserializer(final MapType type, final DeserializationConfig config, BeanDescription beanDesc, final KeyDeserializer keyDeserializer,
        final TypeDeserializer elementTypeDeserializer, final JsonDeserializer<?> elementDeserializer) throws JsonMappingException {

    if (ImmutableMap.class.isAssignableFrom(type.getRawClass())) {
        return new StdDeserializer<Object>(type) {
            private static final long serialVersionUID = 1L;

            @Override
            public Object deserialize(JsonParser jp, DeserializationContext context) throws IOException {

                JsonToken t = jp.getCurrentToken();
                if (t == JsonToken.START_OBJECT) {
                    t = jp.nextToken();
                }
                if (t != JsonToken.FIELD_NAME && t != JsonToken.END_OBJECT) {
                    throw context.mappingException(type.getRawClass());
                }

                MutableMap<Object, Object> m = Maps.mutable.of();

                for (; jp.getCurrentToken() == JsonToken.FIELD_NAME; jp.nextToken()) {
                    // Pointing to field name
                    String fieldName = jp.getCurrentName();
                    Object key = (keyDeserializer == null) ? fieldName : keyDeserializer.deserializeKey(fieldName, context);
                    t = jp.nextToken();

                    Object value;
                    if (t == JsonToken.VALUE_NULL) {
                        value = null;
                    }
                    else if (elementDeserializer == null) {
                        value = jp.readValueAs(type.getContentType().getRawClass());
                    }
                    else if (elementTypeDeserializer == null) {
                        value = elementDeserializer.deserialize(jp, context);
                    }
                    else {
                        value = elementDeserializer.deserializeWithType(jp, context, elementTypeDeserializer);
                    }
                    m.put(key, value);
                }
                return m.toImmutable();
            }
        };
    }

    return super.findMapDeserializer(type, config, beanDesc, keyDeserializer, elementTypeDeserializer, elementDeserializer);
}
 
開發者ID:kaaprotech,項目名稱:satu,代碼行數:50,代碼來源:SatuDeserializers.java


注:本文中的com.fasterxml.jackson.databind.JsonDeserializer.deserializeWithType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。