當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonReader.beginArray方法代碼示例

本文整理匯總了Java中com.google.gson.stream.JsonReader.beginArray方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonReader.beginArray方法的具體用法?Java JsonReader.beginArray怎麽用?Java JsonReader.beginArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gson.stream.JsonReader的用法示例。


在下文中一共展示了JsonReader.beginArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
public Object read(JsonReader in) throws IOException {
  if (in.peek() == JsonToken.NULL) {
    in.nextNull();
    return null;
  }

  List<E> list = new ArrayList<E>();
  in.beginArray();
  while (in.hasNext()) {
    E instance = componentTypeAdapter.read(in);
    list.add(instance);
  }
  in.endArray();
  Object array = Array.newInstance(componentType, list.size());
  for (int i = 0; i < list.size(); i++) {
    Array.set(array, i, list.get(i));
  }
  return array;
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:20,代碼來源:ArrayTypeAdapter.java

示例2: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
public Object read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
    }
    List<E> list = new ArrayList();
    in.beginArray();
    while (in.hasNext()) {
        list.add(this.componentTypeAdapter.read(in));
    }
    in.endArray();
    Object array = Array.newInstance(this.componentType, list.size());
    for (int i = 0; i < list.size(); i++) {
        Array.set(array, i, list.get(i));
    }
    return array;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:18,代碼來源:ArrayTypeAdapter.java

示例3: readNonNull

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
protected Set<T> readNonNull(JsonReader in) throws IOException {
    final EnumSet<T> set = EnumSet.noneOf(type);
    in.beginArray();
    while(in.hasNext()) {
        final String name = in.nextString();
        final T element;
        try {
            element = Enum.valueOf(type, name);
        } catch(IllegalArgumentException e) {
            continue;
        }
        set.add(element);
    }
    in.endArray();
    return set;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:18,代碼來源:LenientEnumSetTypeAdapter.java

示例4: readHistoryJson

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public List<Address> readHistoryJson(final InputStream in) throws JsonParsingException {
    try {
        JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
        List<Address> addresses = new ArrayList<>();
        reader.beginArray();
        while (reader.hasNext()) {
            Address message = gson.fromJson(reader, Address.class);
            addresses.add(message);
        }
        reader.endArray();
        reader.close();
        return addresses;
    } catch (Exception e) {
        throw new JsonParsingException(e);
    }
}
 
開發者ID:RacZo,項目名稱:Smarty-Streets-AutoCompleteTextView,代碼行數:18,代碼來源:GsonSmartyStreetsApiJsonParser.java

示例5: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public List<Car3> read(JsonReader in) throws IOException {
    List<Car3> list = new ArrayList<>();
    in.beginArray();
    while (in.hasNext()){
        switch (in.peek()){
            case BEGIN_OBJECT:
               // log("BEGIN_OBJECT");
                list.add(mAdapter.read(in));
                break;
        }
    }
    in.endArray();
    return list;
}
 
開發者ID:LightSun,項目名稱:data-mediator,代碼行數:16,代碼來源:ListCar3TypeAdapter.java

示例6: deserialize

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public void deserialize(JsonReader reader) throws IOException {
    reader.beginArray();
    while(reader.hasNext()) {
        add(reader.nextString());
    }
    reader.endArray();
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:9,代碼來源:TagProperty.java

示例7: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override public JsonElement read(JsonReader in) throws IOException {
  switch (in.peek()) {
  case STRING:
    return new JsonPrimitive(in.nextString());
  case NUMBER:
    String number = in.nextString();
    return new JsonPrimitive(new LazilyParsedNumber(number));
  case BOOLEAN:
    return new JsonPrimitive(in.nextBoolean());
  case NULL:
    in.nextNull();
    return JsonNull.INSTANCE;
  case BEGIN_ARRAY:
    JsonArray array = new JsonArray();
    in.beginArray();
    while (in.hasNext()) {
      array.add(read(in));
    }
    in.endArray();
    return array;
  case BEGIN_OBJECT:
    JsonObject object = new JsonObject();
    in.beginObject();
    while (in.hasNext()) {
      object.add(in.nextName(), read(in));
    }
    in.endObject();
    return object;
  case END_DOCUMENT:
  case NAME:
  case END_OBJECT:
  case END_ARRAY:
  default:
    throw new IllegalArgumentException();
  }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:37,代碼來源:TypeAdapters.java

示例8: readStringArray

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
public List<String> readStringArray(JsonReader reader) throws IOException {
    List<String> colors = new ArrayList<String>();
    reader.beginArray();
    while (reader.hasNext()) {
        colors.add(reader.nextString());
    }
    reader.endArray();
    return colors;
}
 
開發者ID:LightSun,項目名稱:data-mediator,代碼行數:10,代碼來源:StringArrayAdapter.java

示例9: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public PlayerId read(JsonReader in) throws IOException {
    in.beginArray();
    String player_id = in.nextString();
    String username = in.nextString();
    String _id = in.nextString();
    in.endArray();

    return new SimplePlayerId(_id, player_id, username);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:11,代碼來源:PlayerIdTypeAdapter.java

示例10: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
public Collection<E> read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
    }
    Collection<E> collection = (Collection) this.constructor.construct();
    in.beginArray();
    while (in.hasNext()) {
        collection.add(this.elementTypeAdapter.read(in));
    }
    in.endArray();
    return collection;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:14,代碼來源:CollectionTypeAdapterFactory.java

示例11: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
public Object read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case BEGIN_ARRAY:
            List<Object> list = new ArrayList();
            in.beginArray();
            while (in.hasNext()) {
                list.add(read(in));
            }
            in.endArray();
            return list;
        case BEGIN_OBJECT:
            Map<String, Object> map = new LinkedHashMap();
            in.beginObject();
            while (in.hasNext()) {
                map.put(in.nextName(), read(in));
            }
            in.endObject();
            return map;
        case STRING:
            return in.nextString();
        case NUMBER:
            return Double.valueOf(in.nextDouble());
        case BOOLEAN:
            return Boolean.valueOf(in.nextBoolean());
        case NULL:
            in.nextNull();
            return null;
        default:
            throw new IllegalStateException();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:32,代碼來源:ObjectTypeAdapter.java

示例12: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
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;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:33,代碼來源:MapTypeAdapterFactory.java

示例13: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
public JsonElement read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NUMBER:
            return new JsonPrimitive(new LazilyParsedNumber(in.nextString()));
        case BOOLEAN:
            return new JsonPrimitive(Boolean.valueOf(in.nextBoolean()));
        case STRING:
            return new JsonPrimitive(in.nextString());
        case NULL:
            in.nextNull();
            return JsonNull.INSTANCE;
        case BEGIN_ARRAY:
            JsonElement array = new JsonArray();
            in.beginArray();
            while (in.hasNext()) {
                array.add(read(in));
            }
            in.endArray();
            return array;
        case BEGIN_OBJECT:
            JsonElement object = new JsonObject();
            in.beginObject();
            while (in.hasNext()) {
                object.add(in.nextName(), read(in));
            }
            in.endObject();
            return object;
        default:
            throw new IllegalArgumentException();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:32,代碼來源:TypeAdapters.java

示例14: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override public Object read(JsonReader in) throws IOException {
  JsonToken token = in.peek();
  switch (token) {
  case BEGIN_ARRAY:
    List<Object> list = new ArrayList<Object>();
    in.beginArray();
    while (in.hasNext()) {
      list.add(read(in));
    }
    in.endArray();
    return list;

  case BEGIN_OBJECT:
    Map<String, Object> map = new LinkedTreeMap<String, Object>();
    in.beginObject();
    while (in.hasNext()) {
      map.put(in.nextName(), read(in));
    }
    in.endObject();
    return map;

  case STRING:
    return in.nextString();

  case NUMBER:
    return in.nextDouble();

  case BOOLEAN:
    return in.nextBoolean();

  case NULL:
    in.nextNull();
    return null;

  default:
    throw new IllegalStateException();
  }
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:39,代碼來源:ObjectTypeAdapter.java

示例15: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
public Object read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case BEGIN_ARRAY:
            List<Object> list = new ArrayList();
            in.beginArray();
            while (in.hasNext()) {
                list.add(read(in));
            }
            in.endArray();
            return list;
        case BEGIN_OBJECT:
            Map<String, Object> map = new LinkedTreeMap();
            in.beginObject();
            while (in.hasNext()) {
                map.put(in.nextName(), read(in));
            }
            in.endObject();
            return map;
        case STRING:
            return in.nextString();
        case NUMBER:
            return Double.valueOf(in.nextDouble());
        case BOOLEAN:
            return Boolean.valueOf(in.nextBoolean());
        case NULL:
            in.nextNull();
            return null;
        default:
            throw new IllegalStateException();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:32,代碼來源:ObjectTypeAdapter.java


注:本文中的com.google.gson.stream.JsonReader.beginArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。