当前位置: 首页>>代码示例>>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;未经允许,请勿转载。