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


Java JsonToken.isScalarValue方法代码示例

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


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

示例1: doMerge

import com.fasterxml.jackson.core.JsonToken; //导入方法依赖的package包/类
@Override
public void doMerge(JsonParser parser, int currentDepth, Message.Builder messageBuilder)
    throws IOException {
  Value.Builder builder = (Value.Builder) messageBuilder;
  JsonToken token = parser.currentToken();
  if (token.isBoolean()) {
    builder.setBoolValue(ParseSupport.parseBool(parser));
  } else if (token.isNumeric()) {
    builder.setNumberValue(ParseSupport.parseDouble(parser));
  } else if (token == JsonToken.VALUE_NULL) {
    builder.setNullValue(NullValue.NULL_VALUE);
  } else if (token.isScalarValue()) {
    builder.setStringValue(ParseSupport.parseString(parser));
  } else if (token == JsonToken.START_OBJECT) {
    Struct.Builder structBuilder = builder.getStructValueBuilder();
    StructMarshaller.INSTANCE.mergeValue(parser, currentDepth + 1, structBuilder);
  } else if (token == JsonToken.START_ARRAY) {
    ListValue.Builder listValueBuilder = builder.getListValueBuilder();
    ListValueMarshaller.INSTANCE.mergeValue(parser, currentDepth + 1, listValueBuilder);
  } else {
    throw new IllegalStateException("Unexpected json data: " + parser.getText());
  }
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:24,代码来源:WellKnownTypeMarshaller.java

示例2: processToken

import com.fasterxml.jackson.core.JsonToken; //导入方法依赖的package包/类
private JsonToken processToken(JsonToken curToken, JsonParser parser, JsonGenerator jgen)
    throws IOException {
  if (curToken.isStructEnd()) {
    // this is our escape and base case.
    return curToken;
  }
  if (curToken.isStructStart()) {
    processStructStart(curToken, jgen);
    JsonToken token = processToken(parser.nextToken(), parser, jgen);
    while (!token.isStructEnd()) {
      token = processToken(token, parser, jgen);
    }
    processStructEnd(token, jgen);
    return parser.nextToken();
  }

  if (curToken.id() == JsonTokenId.ID_FIELD_NAME) {
    String currentName = parser.getCurrentName();
    if (isFiltered && filters.containsKey(parser.getCurrentName())) {
      jgen.writeFieldName(currentName);
      // perform filtering.
      return filters.get(parser.getCurrentName()).processToken(parser.nextToken(), parser, jgen);
    } else if (!isFiltered) {
      jgen.writeFieldName(currentName);
      return processToken(parser.nextToken(), parser, jgen);
    } else {
      parser.nextToken();
      parser.skipChildren();
      return processToken(parser.nextToken(), parser, jgen);
    }
  } else if (curToken.isScalarValue()) {
    processValue(curToken, parser, jgen);
    return parser.nextToken();
  } else {
    LOGGER.error(
        "Unable to process the token {} with name {}.", curToken, parser.getCurrentName());
    throw new RuntimeException(
        "Unable to process the token " + curToken + " with name" + parser.getCurrentName());
  }
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:41,代码来源:FieldFilter.java

示例3: jsonStreamToRecords

import com.fasterxml.jackson.core.JsonToken; //导入方法依赖的package包/类
public static void jsonStreamToRecords(HashSet<String> indexes, JsonParser jp, String path, Consumer<JsonRecord> consumer) throws IOException {
    boolean inArray = false;
    int arrayIndex = 0;
    while (true) {
        JsonToken nextToken = jp.nextToken();

        String currentPath = path;

        if (nextToken == FIELD_NAME) {
            if (inArray) {
                currentPath = path + toArrayIndexPath(arrayIndex) + "/";
            }
            jsonStreamToRecords(indexes, jp, currentPath + validateKey(jp.getCurrentName()) + "/", consumer);
        } else if (nextToken == VALUE_NULL) {
            if (inArray) {
                currentPath = path + toArrayIndexPath(arrayIndex) + "/";
            }
            consumer.accept(JsonRecord.of(currentPath, "", nextToken.id(), indexFieldValue(indexes, currentPath)));
            if( inArray ) {
                arrayIndex++;
            } else {
                return;
            }
        } else if (nextToken.isScalarValue()) {
            if (inArray) {
                currentPath = path + toArrayIndexPath(arrayIndex) + "/";
            }
            consumer.accept(JsonRecord.of(currentPath, jp.getValueAsString(), nextToken.id(), indexFieldValue(indexes, currentPath)));
            if( inArray ) {
                arrayIndex++;
            } else {
                return;
            }
        } else if (nextToken == END_OBJECT) {
            if( inArray ) {
                arrayIndex++;
            } else {
                return;
            }
        } else if (nextToken == START_ARRAY) {
            inArray = true;
        } else if (nextToken == END_ARRAY) {
            return;
        }
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:47,代码来源:JsonRecordSupport.java


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