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


Java JsonDeserializer.deserialize方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.JsonDeserializer.deserialize方法的典型用法代码示例。如果您正苦于以下问题:Java JsonDeserializer.deserialize方法的具体用法?Java JsonDeserializer.deserialize怎么用?Java JsonDeserializer.deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.JsonDeserializer的用法示例。


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

示例1: deserialize

import com.fasterxml.jackson.databind.JsonDeserializer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Analyzer<?> deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
	final JsonDeserializer<?> specDeserializer = ctxt
			.findNonContextualValueDeserializer(TypeFactory.defaultInstance().uncheckedSimpleType(AnalyzerSpec.class));

	final AnalyzerSpec spec = (AnalyzerSpec) specDeserializer.deserialize(p, ctxt);

	final AnalyzerCreationResult creationResult = spec.getAnalyzerType().tryCreateAnalyzer(spec);
	if (!creationResult.wasSuccessful()) {
		throw new IOException(
				"Could not create analyzer from spec, global result: " + creationResult.getGlobalResult() + ", parameter results: ");
	}

	return creationResult.getAnalyzer();
}
 
开发者ID:mizitch,项目名称:story-inspector,代码行数:17,代码来源:JsonMappingSpringConfig.java

示例2: _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

示例3: _deserializeTypedUsingDefaultImpl

import com.fasterxml.jackson.databind.JsonDeserializer; //导入方法依赖的package包/类
protected Object _deserializeTypedUsingDefaultImpl(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, TokenBuffer paramTokenBuffer)
{
  JsonDeserializer localJsonDeserializer = _findDefaultImplDeserializer(paramDeserializationContext);
  if (localJsonDeserializer != null)
  {
    if (paramTokenBuffer != null)
    {
      paramTokenBuffer.writeEndObject();
      JsonParser localJsonParser = paramTokenBuffer.asParser(paramJsonParser);
      paramJsonParser = localJsonParser;
      localJsonParser.nextToken();
    }
    return localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
  }
  Object localObject = TypeDeserializer.deserializeIfNatural(paramJsonParser, paramDeserializationContext, this._baseType);
  if (localObject != null)
    return localObject;
  if (paramJsonParser.getCurrentToken() == JsonToken.START_ARRAY)
    return super.deserializeTypedFromAny(paramJsonParser, paramDeserializationContext);
  throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.FIELD_NAME, "missing property '" + this._typePropertyName + "' that is to contain type id  (for class " + baseTypeName() + ")");
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:22,代码来源:AsPropertyTypeDeserializer.java

示例4: _deserialize

import com.fasterxml.jackson.databind.JsonDeserializer; //导入方法依赖的package包/类
private final Object _deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
{
  boolean bool = paramJsonParser.isExpectedStartArrayToken();
  String str = _locateTypeId(paramJsonParser, paramDeserializationContext);
  JsonDeserializer localJsonDeserializer = _findDeserializer(paramDeserializationContext, str);
  if ((this._typeIdVisible) && (paramJsonParser.getCurrentToken() == JsonToken.START_OBJECT))
  {
    TokenBuffer localTokenBuffer = new TokenBuffer(null);
    localTokenBuffer.writeStartObject();
    localTokenBuffer.writeFieldName(this._typePropertyName);
    localTokenBuffer.writeString(str);
    JsonParserSequence localJsonParserSequence = JsonParserSequence.createFlattened(localTokenBuffer.asParser(paramJsonParser), paramJsonParser);
    paramJsonParser = localJsonParserSequence;
    localJsonParserSequence.nextToken();
  }
  Object localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
  if ((bool) && (paramJsonParser.nextToken() != JsonToken.END_ARRAY))
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.END_ARRAY, "expected closing END_ARRAY after type information and deserialized value");
  return localObject;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:21,代码来源:AsArrayTypeDeserializer.java

示例5: _deserialize

import com.fasterxml.jackson.databind.JsonDeserializer; //导入方法依赖的package包/类
private final Object _deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
{
  if (paramJsonParser.getCurrentToken() != JsonToken.START_OBJECT)
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.START_OBJECT, "need JSON Object to contain As.WRAPPER_OBJECT type information for class " + baseTypeName());
  if (paramJsonParser.nextToken() != JsonToken.FIELD_NAME)
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.FIELD_NAME, "need JSON String that contains type id (for subtype of " + baseTypeName() + ")");
  String str = paramJsonParser.getText();
  JsonDeserializer localJsonDeserializer = _findDeserializer(paramDeserializationContext, str);
  paramJsonParser.nextToken();
  if ((this._typeIdVisible) && (paramJsonParser.getCurrentToken() == JsonToken.START_OBJECT))
  {
    TokenBuffer localTokenBuffer = new TokenBuffer(null);
    localTokenBuffer.writeStartObject();
    localTokenBuffer.writeFieldName(this._typePropertyName);
    localTokenBuffer.writeString(str);
    JsonParserSequence localJsonParserSequence = JsonParserSequence.createFlattened(localTokenBuffer.asParser(paramJsonParser), paramJsonParser);
    paramJsonParser = localJsonParserSequence;
    localJsonParserSequence.nextToken();
  }
  Object localObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
  if (paramJsonParser.nextToken() != JsonToken.END_OBJECT)
    throw paramDeserializationContext.wrongTokenException(paramJsonParser, JsonToken.END_OBJECT, "expected closing END_OBJECT after type information and deserialized value");
  return localObject;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:25,代码来源:AsWrapperTypeDeserializer.java

示例6: deserializeUsingCustom

import com.fasterxml.jackson.databind.JsonDeserializer; //导入方法依赖的package包/类
private Collection<String> deserializeUsingCustom(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection, JsonDeserializer<String> paramJsonDeserializer)
{
  while (true)
  {
    JsonToken localJsonToken = paramJsonParser.nextToken();
    if (localJsonToken == JsonToken.END_ARRAY)
      break;
    String str;
    if (localJsonToken == JsonToken.VALUE_NULL)
      str = null;
    else
      str = (String)paramJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
    paramCollection.add(str);
  }
  return paramCollection;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:17,代码来源:StringCollectionDeserializer.java

示例7: 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

示例8: 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

示例9: deserializeTypedFromObject

import com.fasterxml.jackson.databind.JsonDeserializer; //导入方法依赖的package包/类
@Override
public Object deserializeTypedFromObject(final JsonParser jp, final DeserializationContext ctxt) throws IOException {
	JsonNode node = jp.readValueAsTree();

	NamedDefinition res = NamedProviders.get((Class<NamedDefinition>) _baseType.getRawClass(), node.get("type").asText());
	if (res == null) {
		return null;
	}
	JavaType type = SimpleType.construct(res.getClass());

	JsonParser jsonParser = new TreeTraversingParser(node, jp.getCodec());
	if (jsonParser.getCurrentToken() == null) {
		jsonParser.nextToken();
	}
	JsonDeserializer<Object> deser = ctxt.findContextualValueDeserializer(type, _property);
	return deser.deserialize(jsonParser, ctxt);
}
 
开发者ID:Treydone,项目名称:mandrel,代码行数:18,代码来源:DynamicPropertyTypeDeserializer.java

示例10: _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

示例11: _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

示例12: _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

示例13: shouldThrowOnNullTree

import com.fasterxml.jackson.databind.JsonDeserializer; //导入方法依赖的package包/类
@Test
public void shouldThrowOnNullTree() throws Exception {
    exception.expect(JWTDecodeException.class);
    exception.expectMessage("Parsing the Header's JSON resulted on a Null map");

    JsonDeserializer deserializer = new HeaderDeserializer();
    JsonParser parser = mock(JsonParser.class);
    ObjectCodec codec = mock(ObjectCodec.class);
    DeserializationContext context = mock(DeserializationContext.class);

    when(codec.readValue(eq(parser), any(TypeReference.class))).thenReturn(null);
    when(parser.getCodec()).thenReturn(codec);

    deserializer.deserialize(parser, context);
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:16,代码来源:HeaderDeserializerTest.java

示例14: deserialize

import com.fasterxml.jackson.databind.JsonDeserializer; //导入方法依赖的package包/类
@Override
public Object deserialize(JsonParser p, DeserializationContext ctx) throws IOException {
    if(jobsManager == null) {
        throw new IllegalStateException("This deserializer need a jobsManager instance, see 'JobParametersDeserializer.setJobsManager'");
    }
    final JsonStreamContext jsc = p.getParsingContext();
    String paramName = null;
    JsonStreamContext parent = jsc;
    while(parent != null) {
        paramName = parent.getCurrentName();
        if(paramName != null) {
            break;
        }
        parent = parent.getParent();
    }
    if(parent == null) {
        throw new NullPointerException("Something wrong: we can not find our parent object, " +
          "may be you use this deserializer on custom object?");
    }
    JobParameters.Builder r = (JobParameters.Builder) parent.getParent().getCurrentValue();
    String jobType = r.getType();
    JobDescription desc = jobsManager.getDescription(jobType);
    JobParameterDescription param = desc.getParameters().get(paramName);
    TypeFactory typeFactory = ctx.getTypeFactory();
    JavaType type;
    if(param == null) {
        type = typeFactory.constructType(Object.class);
    } else {
        type = typeFactory.constructType(param.getType());
    }
    JsonDeserializer<Object> deser = ctx.findNonContextualValueDeserializer(type);
    try {
        return deser.deserialize(p, ctx);
    } catch (Exception e) {
        throw new RuntimeException("Can not deserialize '" + jobType + "." + paramName + "' job parameter ", e );
    }
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:38,代码来源:JobParametersDeserializer.java

示例15: deserialize

import com.fasterxml.jackson.databind.JsonDeserializer; //导入方法依赖的package包/类
@Override
public List<Object> deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    List<Object> result = new ArrayList<Object>();
    JsonDeserializer<Object> deser = ctxt.findRootValueDeserializer(contentType);
    Object object;

    // links is an object, so we parse till we find its end.
    while (!JsonToken.END_OBJECT.equals(jp.nextToken())) {
        if (!JsonToken.FIELD_NAME.equals(jp.getCurrentToken())) {
            throw new JsonParseException("Expected relation name", jp.getCurrentLocation());
        }

        if (JsonToken.START_ARRAY.equals(jp.nextToken())) {
            while (!JsonToken.END_ARRAY.equals(jp.nextToken())) {
                object = deser.deserialize(jp, ctxt);
                ;
                result.add(object);
            }
        } else {
            object = deser.deserialize(jp, ctxt);
            result.add(object);
        }
    }

    return result;
}
 
开发者ID:mockitoo,项目名称:spring-data-rest-android,代码行数:29,代码来源:Jackson2HalModule.java


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