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


Java JsonToken.equals方法代码示例

本文整理汇总了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.");
    }
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:24,代码来源:JsonJacksonFormat.java

示例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..
    }
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:25,代码来源:JsonJacksonFormat.java

示例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();
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:40,代码来源:JsonJacksonFormat.java


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