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