本文整理汇总了Java中com.fasterxml.jackson.core.JsonToken.equals方法的典型用法代码示例。如果您正苦于以下问题:Java JsonToken.equals方法的具体用法?Java JsonToken.equals怎么用?Java JsonToken.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.core.JsonToken
的用法示例。
在下文中一共展示了JsonToken.equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: merge
import com.fasterxml.jackson.core.JsonToken; //导入方法依赖的package包/类
/**
* Parse a text-format message from {@code input} and merge the contents into {@code builder}.
* Extensions will be recognized if they are registered in {@code extensionRegistry}.
* @throws IOException
*/
public void merge(JsonParser parser,
ExtensionRegistry extensionRegistry,
Message.Builder builder) throws IOException {
JsonToken token = parser.nextToken();
if (token.equals(JsonToken.START_OBJECT)) {
token = parser.nextToken();
}
while (token != null && !token.equals(JsonToken.END_OBJECT)) {
mergeField(parser, extensionRegistry, builder);
token = parser.nextToken();
}
// Test to make sure the tokenizer has reached the end of the stream.
if (parser.nextToken() != null) {
throw new RuntimeException("Expecting the end of the stream, but there seems to be more data! Check the input for a valid JSON format.");
}
}
示例2: handleMissingField
import com.fasterxml.jackson.core.JsonToken; //导入方法依赖的package包/类
private void handleMissingField(String fieldName, JsonParser parser,
ExtensionRegistry extensionRegistry,
UnknownFieldSet.Builder builder) throws IOException {
JsonToken token = parser.nextToken();
if (token.equals(JsonToken.START_OBJECT)) {
// Message structure
token = parser.nextToken(); // skip name
while (token != null && !token.equals(JsonToken.END_OBJECT)) {
handleMissingField(fieldName, parser, extensionRegistry, builder);
token = parser.nextToken(); // get } or field name
}
} else if (token.equals(JsonToken.START_ARRAY)) {
// Collection
do {
handleMissingField(fieldName, parser, extensionRegistry, builder);
token = parser.getCurrentToken(); // got value or ]
} while (token != null && !token.equals(JsonToken.END_ARRAY));
} else {
// Primitive value
// NULL, INT, BOOL, STRING
// nothing to do..
}
}
示例3: handleObject
import com.fasterxml.jackson.core.JsonToken; //导入方法依赖的package包/类
private Object handleObject(JsonParser parser,
ExtensionRegistry extensionRegistry,
Message.Builder builder,
FieldDescriptor field,
ExtensionRegistry.ExtensionInfo extension,
boolean unknown) throws IOException {
Message.Builder subBuilder;
if (extension == null) {
subBuilder = builder.newBuilderForField(field);
} else {
subBuilder = extension.defaultInstance.newBuilderForType();
}
JsonToken token = parser.getCurrentToken();
if (JsonToken.VALUE_NULL == token) {
return null;
}
if (unknown) {
ByteString data = ByteString.copyFrom(parser.getBinaryValue());
try {
subBuilder.mergeFrom(data);
return subBuilder.build();
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException("Failed to build " + field.getFullName() + " from " + data);
}
}
//token = parser.nextToken();
if (token.equals(JsonToken.START_OBJECT)) {
token = parser.nextToken();
while (token != null && !token.equals(JsonToken.END_OBJECT)) {
mergeField(parser, extensionRegistry, subBuilder);
token = parser.nextToken();
}
}
return subBuilder.build();
}