本文整理汇总了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());
}
}
示例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());
}
}
示例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;
}
}
}