com.fasterxml.jackson.databind.ObjectMapper.createDeserializationContext()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(89)

本文整理了Java中com.fasterxml.jackson.databind.ObjectMapper.createDeserializationContext()方法的一些代码示例,展示了ObjectMapper.createDeserializationContext()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectMapper.createDeserializationContext()方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.ObjectMapper
类名称:ObjectMapper
方法名:createDeserializationContext

ObjectMapper.createDeserializationContext介绍

[英]Internal helper method called to create an instance of DeserializationContextfor deserializing a single root value. Can be overridden if a custom context is needed.
[中]

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Method similar to {@link #canDeserialize(JavaType)} but that can return
 * actual {@link Throwable} that was thrown when trying to construct
 * serializer: this may be useful in figuring out what the actual problem is.
 * 
 * @since 2.3
 */
public boolean canDeserialize(JavaType type, AtomicReference<Throwable> cause)
{
  return createDeserializationContext(null,
      getDeserializationConfig()).hasValueDeserializerFor(type, cause);
}

代码示例来源:origin: redisson/redisson

/**
 * Method that can be called to check whether mapper thinks
 * it could deserialize an Object of given type.
 * Check is done by checking whether a registered deserializer can
 * be found or built for the type; if not (either by no mapping being
 * found, or through an <code>Exception</code> being thrown, false
 * is returned.
 *<p>
 * <b>NOTE</b>: in case an exception is thrown during course of trying
 * co construct matching deserializer, it will be effectively swallowed.
 * If you want access to that exception, call
 * {@link #canDeserialize(JavaType, AtomicReference)} instead.
 *
 * @return True if mapper can find a serializer for instances of
 *  given class (potentially serializable), false otherwise (not
 *  serializable)
 */
public boolean canDeserialize(JavaType type)
{
  return createDeserializationContext(null,
      getDeserializationConfig()).hasValueDeserializerFor(type, null);
}

代码示例来源:origin: redisson/redisson

/**
 * Convenience method, equivalent in function to:
 *<pre>
 *   readerFor(valueType).readValues(p);
 *</pre>
 *<p>
 * Type-safe overload of {@link #readValues(JsonParser, ResolvedType)}.
 */
public <T> MappingIterator<T> readValues(JsonParser p, JavaType valueType)
  throws IOException, JsonProcessingException
{
  DeserializationConfig config = getDeserializationConfig();
  DeserializationContext ctxt = createDeserializationContext(p, config);
  JsonDeserializer<?> deser = _findRootDeserializer(ctxt, valueType);
  // false -> do NOT close JsonParser (since caller passed it)
  return new MappingIterator<T>(valueType, p, ctxt, deser,
      false, null);
}

代码示例来源:origin: redisson/redisson

JsonToken t = _initForReading(p, toValueType);
if (t == JsonToken.VALUE_NULL) {
  DeserializationContext ctxt = createDeserializationContext(p, deserConfig);
  result = _findRootDeserializer(ctxt, toValueType).getNullValue(ctxt);
} else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) {
  result = null;
} else { // pointing to event other than null
  DeserializationContext ctxt = createDeserializationContext(p, deserConfig);
  JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, toValueType);

代码示例来源:origin: redisson/redisson

return cfg.getNodeFactory().nullNode();
DeserializationContext ctxt = createDeserializationContext(p, cfg);
JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, valueType);
Object result;

代码示例来源:origin: redisson/redisson

final DeserializationContext ctxt = createDeserializationContext(p, cfg);
if (t == JsonToken.VALUE_NULL) {

代码示例来源:origin: redisson/redisson

protected Object _readMapAndClose(JsonParser p0, JavaType valueType)
  throws IOException
{
  try (JsonParser p = p0) {
    Object result;
    JsonToken t = _initForReading(p, valueType);
    final DeserializationConfig cfg = getDeserializationConfig();
    final DeserializationContext ctxt = createDeserializationContext(p, cfg);
    if (t == JsonToken.VALUE_NULL) {
      // Ask JsonDeserializer what 'null value' to use:
      result = _findRootDeserializer(ctxt, valueType).getNullValue(ctxt);
    } else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) {
      result = null;
    } else {
      JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, valueType);
      if (cfg.useRootWrapping()) {
        result = _unwrapAndDeserialize(p, ctxt, cfg, valueType, deser);
      } else {
        result = deser.deserialize(p, ctxt);
      }
      ctxt.checkUnresolvedObjectId();
    }
    if (cfg.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)) {
      _verifyNoTrailingTokens(p, ctxt, valueType);
    }
    return result;
  }
}

代码示例来源:origin: Nextdoor/bender

/**
 * Method similar to {@link #canDeserialize(JavaType)} but that can return
 * actual {@link Throwable} that was thrown when trying to construct
 * serializer: this may be useful in figuring out what the actual problem is.
 * 
 * @since 2.3
 */
public boolean canDeserialize(JavaType type, AtomicReference<Throwable> cause)
{
  return createDeserializationContext(null,
      getDeserializationConfig()).hasValueDeserializerFor(type, cause);
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

/**
 * Method similar to {@link #canDeserialize(JavaType)} but that can return
 * actual {@link Throwable} that was thrown when trying to construct
 * serializer: this may be useful in figuring out what the actual problem is.
 * 
 * @since 2.3
 */
public boolean canDeserialize(JavaType type, AtomicReference<Throwable> cause)
{
  return createDeserializationContext(null,
      getDeserializationConfig()).hasValueDeserializerFor(type, cause);
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

/**
 * Method similar to {@link #canDeserialize(JavaType)} but that can return
 * actual {@link Throwable} that was thrown when trying to construct
 * serializer: this may be useful in figuring out what the actual problem is.
 * 
 * @since 2.3
 */
public boolean canDeserialize(JavaType type, AtomicReference<Throwable> cause)
{
  return createDeserializationContext(null,
      getDeserializationConfig()).hasValueDeserializerFor(type, cause);
}

代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind

/**
 * Method similar to {@link #canDeserialize(JavaType)} but that can return
 * actual {@link Throwable} that was thrown when trying to construct
 * serializer: this may be useful in figuring out what the actual problem is.
 *
 * @since 2.3
 */
public boolean canDeserialize(JavaType type, AtomicReference<Throwable> cause)
{
  return createDeserializationContext(null,
      getDeserializationConfig()).hasValueDeserializerFor(type, cause);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Method that can be called to check whether mapper thinks
 * it could deserialize an Object of given type.
 * Check is done
 * by checking whether a deserializer can be found for the type.
 *
 * @return True if mapper can find a serializer for instances of
 *  given class (potentially serializable), false otherwise (not
 *  serializable)
 */
public boolean canDeserialize(JavaType type)
{
  return createDeserializationContext(null,
      getDeserializationConfig()).hasValueDeserializerFor(type);
}

代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind

/**
 * Method that can be called to check whether mapper thinks
 * it could deserialize an Object of given type.
 * Check is done
 * by checking whether a deserializer can be found for the type.
 *
 * @return True if mapper can find a serializer for instances of
 *  given class (potentially serializable), false otherwise (not
 *  serializable)
 */
public boolean canDeserialize(JavaType type)
{
  return createDeserializationContext(null,
      getDeserializationConfig()).hasValueDeserializerFor(type);
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

/**
 * Method that can be called to check whether mapper thinks
 * it could deserialize an Object of given type.
 * Check is done by checking whether a registered deserializer can
 * be found or built for the type; if not (either by no mapping being
 * found, or through an <code>Exception</code> being thrown, false
 * is returned.
 *<p>
 * <b>NOTE</b>: in case an exception is thrown during course of trying
 * co construct matching deserializer, it will be effectively swallowed.
 * If you want access to that exception, call
 * {@link #canDeserialize(JavaType, AtomicReference)} instead.
 *
 * @return True if mapper can find a serializer for instances of
 *  given class (potentially serializable), false otherwise (not
 *  serializable)
 */
public boolean canDeserialize(JavaType type)
{
  return createDeserializationContext(null,
      getDeserializationConfig()).hasValueDeserializerFor(type, null);
}

代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind

/**
 * Type-safe overloaded method, basically alias for {@link #readValues(JsonParser, ResolvedType)}.
 */
public <T> MappingIterator<T> readValues(JsonParser jp, JavaType valueType)
    throws IOException, JsonProcessingException
{
  DeserializationConfig config = getDeserializationConfig();
  DeserializationContext ctxt = createDeserializationContext(jp, config);
  JsonDeserializer<?> deser = _findRootDeserializer(ctxt, valueType);
  // false -> do NOT close JsonParser (since caller passed it)
  return new MappingIterator<T>(valueType, jp, ctxt, deser,
      false, null);
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

/**
 * Type-safe overloaded method, basically alias for {@link #readValues(JsonParser, ResolvedType)}.
 */
public <T> MappingIterator<T> readValues(JsonParser jp, JavaType valueType)
    throws IOException, JsonProcessingException
{
  DeserializationConfig config = getDeserializationConfig();
  DeserializationContext ctxt = createDeserializationContext(jp, config);
  JsonDeserializer<?> deser = _findRootDeserializer(ctxt, valueType);
  // false -> do NOT close JsonParser (since caller passed it)
  return new MappingIterator<T>(valueType, jp, ctxt, deser,
      false, null);
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

/**
 * Type-safe overloaded method, basically alias for {@link #readValues(JsonParser, ResolvedType)}.
 */
public <T> MappingIterator<T> readValues(JsonParser jp, JavaType valueType)
    throws IOException, JsonProcessingException
{
  DeserializationConfig config = getDeserializationConfig();
  DeserializationContext ctxt = createDeserializationContext(jp, config);
  JsonDeserializer<?> deser = _findRootDeserializer(ctxt, valueType);
  // false -> do NOT close JsonParser (since caller passed it)
  return new MappingIterator<T>(valueType, jp, ctxt, deser,
      false, null);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Type-safe overloaded method, basically alias for {@link #readValues(JsonParser, ResolvedType)}.
 */
public <T> MappingIterator<T> readValues(JsonParser jp, JavaType valueType)
    throws IOException, JsonProcessingException
{
  DeserializationConfig config = getDeserializationConfig();
  DeserializationContext ctxt = createDeserializationContext(jp, config);
  JsonDeserializer<?> deser = _findRootDeserializer(ctxt, valueType);
  // false -> do NOT close JsonParser (since caller passed it)
  return new MappingIterator<T>(valueType, jp, ctxt, deser,
      false, null);
}

代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind

/**
 * Convenience method, equivalent in function to:
 *<pre>
 *   readerFor(valueType).readValues(p);
 *</pre>
 *<p>
 * Type-safe overload of {@link #readValues(JsonParser, ResolvedType)}.
 */
public <T> MappingIterator<T> readValues(JsonParser p, JavaType valueType)
  throws IOException, JsonProcessingException
{
  DeserializationConfig config = getDeserializationConfig();
  DeserializationContext ctxt = createDeserializationContext(p, config);
  JsonDeserializer<?> deser = _findRootDeserializer(ctxt, valueType);
  // false -> do NOT close JsonParser (since caller passed it)
  return new MappingIterator<T>(valueType, p, ctxt, deser,
      false, null);
}

代码示例来源:origin: Nextdoor/bender

/**
 * Convenience method, equivalent in function to:
 *<pre>
 *   readerFor(valueType).readValues(p);
 *</pre>
 *<p>
 * Type-safe overload of {@link #readValues(JsonParser, ResolvedType)}.
 */
public <T> MappingIterator<T> readValues(JsonParser p, JavaType valueType)
  throws IOException, JsonProcessingException
{
  DeserializationConfig config = getDeserializationConfig();
  DeserializationContext ctxt = createDeserializationContext(p, config);
  JsonDeserializer<?> deser = _findRootDeserializer(ctxt, valueType);
  // false -> do NOT close JsonParser (since caller passed it)
  return new MappingIterator<T>(valueType, p, ctxt, deser,
      false, null);
}

相关文章

微信公众号

最新文章

更多

ObjectMapper类方法