MapTypeAdapterFactory.java 文件源码

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

项目:boohee_v5.6 作者:
public Map<K, V> read(JsonReader in) throws IOException {
    JsonToken peek = in.peek();
    if (peek == JsonToken.NULL) {
        in.nextNull();
        return null;
    }
    Map<K, V> map = (Map) this.constructor.construct();
    K key;
    if (peek == JsonToken.BEGIN_ARRAY) {
        in.beginArray();
        while (in.hasNext()) {
            in.beginArray();
            key = this.keyTypeAdapter.read(in);
            if (map.put(key, this.valueTypeAdapter.read(in)) != null) {
                throw new JsonSyntaxException("duplicate key: " + key);
            }
            in.endArray();
        }
        in.endArray();
        return map;
    }
    in.beginObject();
    while (in.hasNext()) {
        JsonReaderInternalAccess.INSTANCE.promoteNameToValue(in);
        key = this.keyTypeAdapter.read(in);
        if (map.put(key, this.valueTypeAdapter.read(in)) != null) {
            throw new JsonSyntaxException("duplicate key: " + key);
        }
    }
    in.endObject();
    return map;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号