本文整理汇总了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);
}
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
}
示例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();
}
示例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);
}
示例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;
}
示例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());
}
示例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();
}