JsonFormat.java 文件源码

java
阅读 73 收藏 0 点赞 0 评论 0

项目:jigsaw-payment 作者:
/**
 * 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}.
 */
public void merge(CharSequence input,
                         ExtensionRegistry extensionRegistry,
                         Message.Builder builder) throws ParseException {
    Tokenizer tokenizer = new Tokenizer(input);

    // Based on the state machine @ http://json.org/

    tokenizer.consume("{"); // Needs to happen when the object starts.
    while (!tokenizer.tryConsume("}")) { // Continue till the object is done
        mergeField(tokenizer, extensionRegistry, builder);
    }
    // Test to make sure the tokenizer has reached the end of the stream.
    if (!tokenizer.atEnd()) {
        throw tokenizer.parseException("Expecting the end of the stream, but there seems to be more data!  Check the input for a valid JSON format.");
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号