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

x33g5p2x  于2022-01-21 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(199)

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

JsonNode.asToken介绍

[英]Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the first JsonToken that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)
[中]方法,该方法在使用流抽象遍历节点时可用于有效的类型检测。将返回等效流事件将产生的第一个JsonToken(对于大多数节点,只有一个令牌,但是对于结构化/容器类型,有多个令牌)

代码示例

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

@Override
public JsonToken nextToken() {
  if (!_done) {
    _done = true;
    return _node.asToken();
  }
  _node = null;
  return null;
}

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

@Override
public JsonToken nextToken()
{
  if (!_contents.hasNext()) {
    _currentNode = null;
    return null;
  }
  _currentNode = _contents.next();
  return _currentNode.asToken();
}

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

@Override
public JsonToken nextToken()
{
  // Need a new entry?
  if (_needEntry) {
    if (!_contents.hasNext()) {
      _currentName = null;
      _current = null;
      return null;
    }
    _needEntry = false;
    _current = _contents.next();
    _currentName = (_current == null) ? null : _current.getKey();
    return JsonToken.FIELD_NAME;
  }
  _needEntry = true;
  return _current.getValue().asToken();
}

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

protected JsonNode currentNumericNode()
  throws JsonParseException
{
  JsonNode n = currentNode();
  if (n == null || !n.isNumber()) {
    JsonToken t = (n == null) ? null : n.asToken();
    throw _constructError("Current token ("+t+") not numeric, cannot use numeric value accessors");
  }
  return n;
}

代码示例来源:origin: apache/avro

switch(node.asToken()) {
case VALUE_NUMBER_INT:
 out.writeIndex(JsonType.LONG.ordinal());
 break;
default:
 throw new AvroRuntimeException(node.asToken()+" unexpected: "+node);

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

@Override
public JsonToken nextToken() {
  if (!_done) {
    _done = true;
    return _node.asToken();
  }
  _node = null;
  return null;
}

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

@Override
public JsonToken nextToken() {
  if (!_done) {
    _done = true;
    return _node.asToken();
  }
  _node = null;
  return null;
}

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

@Override
public JsonToken nextToken() {
  if (!_done) {
    _done = true;
    return _node.asToken();
  }
  _node = null;
  return null;
}

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

@Override
public JsonToken nextToken() {
  if (!_done) {
    _done = true;
    return _node.asToken();
  }
  _node = null;
  return null;
}

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

@Override
public JsonToken nextToken() {
  if (!_done) {
    _done = true;
    return _node.asToken();
  }
  _node = null;
  return null;
}

代码示例来源:origin: palantir/atlasdb

public static byte[] deserializeVal(ColumnValueDescription description,
    JsonNode node) {
  byte[] bytes;
  switch (description.getFormat()) {
    case PERSISTABLE:
    case PERSISTER:
      bytes = node.asToken().asByteArray();
      break;
    case PROTO:
      Message.Builder builder = DynamicMessage.newBuilder(description.getProtoDescriptor());
      try {
        ForkedJsonFormat.merge(node.toString(), builder);
      } catch (ForkedJsonFormat.ParseException e) {
        throw Throwables.rewrapAndThrowUncheckedException(e);
      }
      bytes = builder.build().toByteArray();
      break;
    case VALUE_TYPE:
      bytes = description.getValueType().convertFromJson(node.toString());
      break;
    default:
      throw new EnumConstantNotPresentException(Format.class, description.getFormat().name());
  }
  return CompressionUtils.compress(bytes, description.getCompression());
}

代码示例来源:origin: com.flipkart.zjsonpatch/zjsonpatch

public static NodeType getNodeType(final JsonNode node) {
    final JsonToken token = node.asToken();
    final NodeType ret = TOKEN_MAP.get(token);
    if (ret == null) throw new NullPointerException("unhandled token type " + token);
    return ret;
  }
}

代码示例来源:origin: flipkart-incubator/zjsonpatch

public static NodeType getNodeType(final JsonNode node) {
    final JsonToken token = node.asToken();
    final NodeType ret = TOKEN_MAP.get(token);
    if (ret == null) throw new NullPointerException("unhandled token type " + token);
    return ret;
  }
}

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

@Override
public JsonToken nextToken()
{
  if (!_contents.hasNext()) {
    _currentNode = null;
    return null;
  }
  _currentNode = _contents.next();
  return _currentNode.asToken();
}

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

@Override
public JsonToken nextToken()
{
  if (!_contents.hasNext()) {
    _currentNode = null;
    return null;
  }
  _currentNode = _contents.next();
  return _currentNode.asToken();
}

代码示例来源:origin: io.fabric8/zjsonpatch

public static NodeType getNodeType(final JsonNode node) {
    final JsonToken token = node.asToken();
    final NodeType ret = TOKEN_MAP.get(token);
    Preconditions.checkNotNull(ret, "unhandled token type " + token);
    return ret;
  }
}

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

protected JsonNode currentNumericNode()
  throws JsonParseException
{
  JsonNode n = currentNode();
  if (n == null || !n.isNumber()) {
    JsonToken t = (n == null) ? null : n.asToken();
    throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors");
  }
  return n;
}

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

protected JsonNode currentNumericNode()
  throws JsonParseException
{
  JsonNode n = currentNode();
  if (n == null || !n.isNumber()) {
    JsonToken t = (n == null) ? null : n.asToken();
    throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors");
  }
  return n;
}

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

protected JsonNode currentNumericNode()
  throws JsonParseException
{
  JsonNode n = currentNode();
  if (n == null || !n.isNumber()) {
    JsonToken t = (n == null) ? null : n.asToken();
    throw _constructError("Current token ("+t+") not numeric, cannot use numeric value accessors");
  }
  return n;
}

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

protected JsonNode currentNumericNode()
  throws JsonParseException
{
  JsonNode n = currentNode();
  if (n == null || !n.isNumber()) {
    JsonToken t = (n == null) ? null : n.asToken();
    throw _constructError("Current token ("+t+") not numeric, can not use numeric value accessors");
  }
  return n;
}

相关文章