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


Java JsonReader.endArray方法代碼示例

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


在下文中一共展示了JsonReader.endArray方法的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: 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

示例3: 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

示例4: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public void read(JsonReader in, GsonProperty property, Object t) throws IOException {
    final Class<?> simpleType = property.getType();

    List list = new ArrayList();
    in.beginArray();
    if (simpleType.isPrimitive() || isBoxedClass(simpleType)) {
        while (in.hasNext()){
            list.add(SupportUtils.readPrimitiveOrItsBox(in, property));
        }
    }else{
        TypeAdapter adapter = getTypeAdapter(simpleType);
        while (in.hasNext()){
            list.add(adapter.read(in));
        }
    }
    setValue(property, t, list);
    in.endArray();
}
 
開發者ID:LightSun,項目名稱:data-mediator,代碼行數:20,代碼來源:TypeHandler.java

示例5: onWebSocketMessage

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@OnMessage
public void onWebSocketMessage(Reader message) throws IOException {

    // [id, pair, price, size, side]
    JsonReader reader = gson.newJsonReader(message);
    reader.beginArray();
    reader.skipValue();
    String pair = reader.nextString();
    String price = reader.nextString();
    String size = reader.nextString();
    reader.skipValue();
    reader.endArray();
    reader.close();

    appendCache(pair, CoincheckTrade.builder()
            .timestamp(getNow())
            .price(new BigDecimal(price))
            .size(new BigDecimal(size))
            .build());

}
 
開發者ID:after-the-sunrise,項目名稱:cryptotrader,代碼行數:22,代碼來源:CoincheckContext.java

示例6: read

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

  BitSet bitset = new BitSet();
  in.beginArray();
  int i = 0;
  JsonToken tokenType = in.peek();
  while (tokenType != JsonToken.END_ARRAY) {
    boolean set;
    switch (tokenType) {
    case NUMBER:
      set = in.nextInt() != 0;
      break;
    case BOOLEAN:
      set = in.nextBoolean();
      break;
    case STRING:
      String stringValue = in.nextString();
      try {
        set = Integer.parseInt(stringValue) != 0;
      } catch (NumberFormatException e) {
        throw new JsonSyntaxException(
            "Error: Expecting: bitset number value (1, 0), Found: " + stringValue);
      }
      break;
    default:
      throw new JsonSyntaxException("Invalid bitset value type: " + tokenType);
    }
    if (set) {
      bitset.set(i);
    }
    ++i;
    tokenType = in.peek();
  }
  in.endArray();
  return bitset;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:41,代碼來源:TypeAdapters.java

示例7: parseParams

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
protected Object parseParams(JsonReader in, String method) throws IOException {
	JsonToken next = in.peek();
	if (next == JsonToken.NULL) {
		in.nextNull();
		return null;
	}
	Type[] parameterTypes = getParameterTypes(method);
	if (parameterTypes.length == 1) {
		return fromJson(in, parameterTypes[0]);
	}
	if (parameterTypes.length > 1 && next == JsonToken.BEGIN_ARRAY) {
		List<Object> parameters = new ArrayList<Object>(parameterTypes.length);
		int index = 0;
		in.beginArray();
		while (in.hasNext()) {
			Type parameterType = index < parameterTypes.length ? parameterTypes[index] : null;
			Object parameter = fromJson(in, parameterType);
			parameters.add(parameter);
			index++;
		}
		in.endArray();
		while (index < parameterTypes.length) {
			parameters.add(null);
			index++;
		}
		return parameters;
	}
	return new JsonParser().parse(in);
}
 
開發者ID:tracymiranda,項目名稱:dsp4e,代碼行數:30,代碼來源:DebugMessageTypeAdapterFactory.java

示例8: setRawGazes

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
public void setRawGazes(JsonReader reader) throws IOException {
	ArrayList<RawGaze> rawGazes = new ArrayList<RawGaze>();
	reader.beginArray();
	while (reader.hasNext()) {
		rawGazes.add(getRawGaze(reader));
	}
	reader.endArray();
	setRawGazes(rawGazes);
}
 
開發者ID:SERESLab,項目名稱:iTrace-Archive,代碼行數:10,代碼來源:JSONBasicFixationFilter.java

示例9: 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

示例10: parseResults

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
private void parseResults(JsonReader reader, JsonWriter writer) throws IOException
{
	reader.beginArray();
	while (reader.hasNext())
	{
		MetricFrom metricFrom = gson.fromJson(reader, MetricFrom.class);
		MetricTo metricTo = new MetricTo(metricFrom);
		gson.toJson(metricTo, MetricTo.class, writer);
	}

	reader.endArray();
}
 
開發者ID:quqiangsheng,項目名稱:abhot,代碼行數:13,代碼來源:ResponseToMetricConverter.java

示例11: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public SemanticVersion read(JsonReader in) throws IOException {
    in.beginArray();
    int major = in.nextInt();
    int minor = in.nextInt();
    int patch = in.peek() == JsonToken.END_ARRAY ? 0 : in.nextInt();
    in.endArray();
    return new SemanticVersion(major, minor, patch);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:10,代碼來源:SemanticVersionTypeAdapter.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: 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,代碼行數:11,代碼來源:Car3TypeAdapter.java

示例14: 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,項目名稱:letv,代碼行數:32,代碼來源:TypeAdapters.java

示例15: 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


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