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


Java JsonReader.endObject方法代碼示例

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


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

示例1: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
public T read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
    }
    T instance = this.constructor.construct();
    try {
        in.beginObject();
        while (in.hasNext()) {
            BoundField field = (BoundField) this.boundFields.get(in.nextName());
            if (field == null || !field.deserialized) {
                in.skipValue();
            } else {
                field.read(in, instance);
            }
        }
        in.endObject();
        return instance;
    } catch (Throwable e) {
        throw new JsonSyntaxException(e);
    } catch (IllegalAccessException e2) {
        throw new AssertionError(e2);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:25,代碼來源:ReflectiveTypeAdapterFactory.java

示例2: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public IStudent read(JsonReader in) throws IOException {
    GsonTest.log("read");
    StudentModuleImpl module = new StudentModuleImpl();
    in.beginObject();
    while (in.hasNext()){
        switch (in.nextName()){
            case "name":
                module.setName(in.nextString());
                break;

            case "id":
                module.setId(in.nextString());
                break;

            default:
                in.skipValue();
        }
    }
    in.endObject();
    return module;
}
 
開發者ID:LightSun,項目名稱:data-mediator,代碼行數:23,代碼來源:StudentTypeAdapter.java

示例3: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override public AnInterface read(JsonReader jsonReader) throws IOException {
  jsonReader.beginObject();

  String name = null;
  while (jsonReader.peek() != JsonToken.END_OBJECT) {
    switch (jsonReader.nextName()) {
      case "name":
        name = jsonReader.nextString();
        break;
    }
  }

  jsonReader.endObject();
  return new AnImplementation(name);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:GsonConverterFactoryTest.java

示例4: setLogInfo

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
public void setLogInfo(JsonReader reader) throws IOException {
	reader.beginObject();
	while (reader.hasNext()) {
		String name = reader.nextName();
		if (name.equals("screen_size")) {
			reader.beginObject();
			while(reader.hasNext()) {
				String name2 = reader.nextName();
				if (name2.equals("width")) {
					width = reader.nextInt();
				} else if (name2.equals("height")) {
					height = reader.nextInt();
				} else {
					reader.skipValue();
				}
			}
			reader.endObject();
		} else {
			reader.skipValue();
		}
	}
	reader.endObject();
}
 
開發者ID:SERESLab,項目名稱:iTrace-Archive,代碼行數:24,代碼來源:JSONBasicFixationFilter.java

示例5: getJobProperties

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
private JobProperties getJobProperties(final JsonReader in) throws IOException {
    JobProperties result = new JobProperties();
    in.beginObject();
    while (in.hasNext()) {
        switch (in.nextName()) {
            case "job_exception_handler":
                result.put(JobProperties.JobPropertiesEnum.JOB_EXCEPTION_HANDLER.getKey(), in.nextString());
                break;
            case "executor_service_handler":
                result.put(JobProperties.JobPropertiesEnum.EXECUTOR_SERVICE_HANDLER.getKey(), in.nextString());
                break;
            default:
                break;
        }
    }
    in.endObject();
    return result;
}
 
開發者ID:elasticjob,項目名稱:elastic-job-cloud,代碼行數:19,代碼來源:AbstractJobConfigurationGsonTypeAdapter.java

示例6: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public RPGItem read(JsonReader in) throws IOException {
    String id = "";
    in.beginObject();
    while (in.hasNext()) {
        switch (in.nextName()) {
            case "identifier":
                id = in.nextString();
                break;
        }
    }
    in.endObject();
    return ItemManager.itemIdentifierToRPGItemMap.getOrDefault(id, null);
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:15,代碼來源:RPGItemAdapter.java

示例7: 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,項目名稱:boohee_v5.6,代碼行數:33,代碼來源:MapTypeAdapterFactory.java

示例8: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public T read(
    final JsonReader in
) throws IOException {

  // support null objects
  if (in.peek() == JsonToken.NULL) {
    // consume object
    in.nextNull();

    // return null
    return null;
  }

  try {
    // try to read union
    return readUnion(in);

  } catch (Exception e) {
    // skip remaining values
    while (in.hasNext()) {
      in.skipValue();
    }

    // assert end of object
    in.endObject();

    // we failed in converting the union
    return null;
  }
}
 
開發者ID:aguther,項目名稱:dds-examples,代碼行數:32,代碼來源:UnionTypeAdapterFactory.java

示例9: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public SparseArray<T> read(JsonReader in) throws IOException {
    SparseArray<T> map = new SparseArray<>();
    in.beginObject();
    while (in.hasNext()){
        String name = in.nextName();
        map.put(Integer.parseInt(name), mAdapter.read(in));
    }
    in.endObject();
    return map;
}
 
開發者ID:LightSun,項目名稱:data-mediator,代碼行數:12,代碼來源:SparseArrayTypeAdapter.java

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

示例11: deserialize

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public void deserialize(JsonReader reader) throws IOException {
    reader.beginObject();

    reader.nextName(); // value
    rawSet(reader.nextString(), true);

    reader.endObject();
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:10,代碼來源:Setting.java

示例12: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public Location read(JsonReader in) throws IOException
{
    in.beginObject();

    in.nextName();
    double x = in.nextDouble();

    in.nextName();
    double y = in.nextDouble();

    in.nextName();
    double z = in.nextDouble();

    in.nextName();
    float pitch = Float.valueOf(String.valueOf(in.nextDouble()));

    in.nextName();
    float yaw = Float.valueOf(String.valueOf(in.nextDouble()));

    in.nextName();
    World world = Bukkit.getWorld(in.nextString());

    in.endObject();

    return new Location(world, x, y, z, pitch, yaw);
}
 
開發者ID:WoutDev,項目名稱:Mega-Walls,代碼行數:28,代碼來源:LocationAdapter.java

示例13: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public Object read(JsonReader in, FieldsReader fieldsReader) throws Exception{
  in.beginObject();
  String typeName = in.nextName();
  Object bean = fieldsReader.instantiateBean(typeName);
  in.beginObject();
  fieldsReader.readFields(bean);
  in.endObject();
  in.endObject();
  return bean;
}
 
開發者ID:rockscript,項目名稱:rockscript,代碼行數:12,代碼來源:PolymorphicTypeNameStrategy.java

示例14: read

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public Location read(JsonReader in) throws IOException {
    in.beginObject();
    Double x = null, y = null, z = null, pitch = null, yaw = null;
    World world = null;
    while (in.hasNext()) {
        String s = in.nextName();
        if (s.equals(WORLD_KEY)) {
            UUID uuid = UUID.fromString(in.nextString());
            world = Bukkit.getWorld(uuid);
            if (world == null)
                throw new JsonParseException("Could not find the world by the UUID: " + uuid.toString());
            continue;
        }
        double v = in.nextDouble();
        switch (s) {
            case X_KEY:
                x = v;
                break;
            case Y_KEY:
                y = v;
                break;
            case Z_KEY:
                z = v;
                break;
            case PITCH:
                pitch = v;
                break;
            case YAW:
                yaw = v;
                break;
        }
    }
    in.endObject();

    if (world == null || x == null || y == null || z == null || pitch == null || yaw == null)
        throw new JsonParseException("Could not read Location object, missing a critical value (expecting world, x, y, z, p, ya)");

    return new Location(world, x, y, z, yaw.floatValue(), pitch.floatValue());
}
 
開發者ID:Twister915,項目名稱:pl,代碼行數:41,代碼來源:LocationTypeAdapter.java

示例15: deserialize

import com.google.gson.stream.JsonReader; //導入方法依賴的package包/類
@Override
public void deserialize(JsonReader reader) throws IOException {
    reader.beginObject();

    while(reader.hasNext()) {
        switch (reader.nextName()) {
            case "enabled":
                setEnabled(reader.nextBoolean());
                break;
            case "keyword":
                setKeyword(reader.nextString());
                break;
            case "type":
                setType(reader.nextString());
                break;
            case "trigger":
                setTrigger(reader.nextString());
                break;
            case "delay":
                setDelay(reader.nextLong());
                break;
            case "messages":
                reader.beginArray();
                while(reader.hasNext()) {
                    add(reader.nextString());
                }
                reader.endArray();
                break;
            default: break;
        }
    }

    reader.endObject();
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:35,代碼來源:SpamEntry.java


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