当前位置: 首页>>代码示例>>Java>>正文


Java JsonReader.nextName方法代码示例

本文整理汇总了Java中com.google.gson.stream.JsonReader.nextName方法的典型用法代码示例。如果您正苦于以下问题:Java JsonReader.nextName方法的具体用法?Java JsonReader.nextName怎么用?Java JsonReader.nextName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gson.stream.JsonReader的用法示例。


在下文中一共展示了JsonReader.nextName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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 "messages":
                reader.beginArray();
                while(reader.hasNext()) {
                    reader.beginObject();
                    MessageEntry entry = new MessageEntry(UUID.fromString(reader.nextName()));
                    entry.deserialize(reader);
                    messages.add(entry);
                    reader.endObject();
                }
                reader.endArray();
                break;
            default: break;
        }
    }

    reader.endObject();
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:24,代码来源:CustomMessageEntry.java

示例2: deserialize

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

    reader.nextName(); // data
    reader.beginObject();
    while(reader.hasNext()) {
        String name = reader.nextName();
        E element = factory.apply(name);
        if(element != null) {
            element.deserialize(reader);
            add(element);
        }
    }
    reader.endObject();

    reader.endObject();
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:19,代码来源:Options.java

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

示例4: parseResponse

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
/**
 * 太绕,还是直接用Json解析吧
 *
 * @param response
 * @throws IOException
 */
private void parseResponse(Reader response) throws IOException {
    JsonReader reader = new JsonReader(response);
    reader.beginObject();
    String name;
    while (reader.hasNext()) {
        name = reader.nextName();
        if (TextUtils.equals(Field.ERROR, name)) {
            reader.nextInt();
        } else if (TextUtils.equals(Field.MESSAGE, name)) {
            reader.nextString();
        } else if (TextUtils.equals(Field.DATA, name)) {
            reader.beginObject();
            while (reader.hasNext()) {
                reader.nextName();
                reader.beginArray();
                while (reader.hasNext()) {
                    reader.beginObject();
                    String itemObjKey;
                    while (reader.hasNext()) {
                        itemObjKey = reader.nextName();
                        if (TextUtils.equals(Field.TOKEN, itemObjKey)) {
                            reader.nextString();
                        } else {
                            reader.skipValue();
                        }
                    }
                    reader.endObject();
                }
                reader.endArray();
            }
            reader.endObject();
        } else {
            reader.skipValue();
        }
    }
    reader.endObject();
    reader.close();
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:45,代码来源:TicketDetailPresenter.java

示例5: getSce

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public SourceCodeEntity getSce(JsonReader reader) throws IOException {
	String name = new String();
	String type = new String();
	String how = new String();
	int length = -1;
	int startLine = -1;
	int endLine = -1;
	int startCol = -1;
	int endCol = -1;
	
	reader.beginObject();
	while(reader.hasNext()) {
		String Name = reader.nextName();
		if (Name.equals("name")) {
			name = reader.nextString();
		} else if (Name.equals("type")) {
			type = reader.nextString();
		} else if (Name.equals("how")) {
			how = reader.nextString();
		} else if (Name.equals("total_length")) {
			length = reader.nextInt();
		} else if (Name.equals("start_line")) {
			startLine = reader.nextInt();
		} else if (Name.equals("end_line")) {
			endLine = reader.nextInt();
		} else if (Name.equals("start_col")) {
			startCol = reader.nextInt();
		} else if (Name.equals("end_col")) {
			endCol = reader.nextInt();
		} else {
			reader.skipValue();
		}
	}
	reader.endObject();
	
	return new SourceCodeEntity(name, type, how, length,
			startLine, endLine, startCol, endCol);
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:39,代码来源:JSONBasicFixationFilter.java

示例6: deserialize

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public void deserialize(final JsonReader reader) throws IOException {
    reader.beginObject();
    while(reader.hasNext()) {
        String name = reader.nextName();
        IBlockProperty property = PropertyFactory.newInstance(name);
        if(property != null) {
            property.deserialize(reader);
            registerProperty(property);
        } else {
            LOGGER.warn(String.format("\"%s\" is not a valid property name", name));
        }
    }
    reader.endObject();
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:16,代码来源:BlockEntry.java

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

示例8: 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 "tag":
                setTag(reader.nextString());
                break;
            case "color":
                setColor(reader.nextInt());
                break;
            case "filtered":
                reader.beginObject();
                // TODO: factory
                while(reader.hasNext()) {
                    try {
                        E instance = FilterFactory.newInstanceByName(reader.nextName());
                        add(instance);
                    } catch (Throwable t) {
                        Helper.handleThrowable(t);
                    }
                }
                reader.endObject();
                break;
        }
    }

    reader.endObject();
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:31,代码来源:FilterEntry.java

示例9: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public Location read(JsonReader in) throws IOException {
    World w = null;
    String worldString = "";
    double x = 0, y = 0, z = 0;
    float yaw = 0, pitch = 0;
    in.beginObject();
    while (in.hasNext()) {
        switch (in.nextName()) {
            case "x":
                x = in.nextDouble();
                break;
            case "y":
                y = in.nextDouble();
                break;
            case "z":
                z = in.nextDouble();
                break;
            case "yaw":
                yaw = (float) in.nextDouble();
                break;
            case "pitch":
                pitch = (float) in.nextDouble();
                break;
            case "worldString":
                worldString = in.nextString();
                break;
        }
    }
    in.endObject();
    w = SakiCore.plugin.getServer().getWorld(worldString);
    if (w == null)
        throw new IOException("Invalid world in JSON: " + worldString + ".");
    return new Location(w, x, y, z, yaw, pitch);
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:36,代码来源:LocationAdapter.java

示例10: build

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
protected Page build(JsonReader reader) throws IOException {
  Page page = new Page();
  while (reader.hasNext()) {
    String key = reader.nextName();
    if (key.equals("pageid")) {
      page.id = reader.nextLong();
    } else if (key.equals("title")) {
      page.title = reader.nextString();
    } else {
      reader.skipValue();
    }
  }
  return page;
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:16,代码来源:WikipediaExample.java

示例11: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public Calendar read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
    }
    in.beginObject();
    int year = 0;
    int month = 0;
    int dayOfMonth = 0;
    int hourOfDay = 0;
    int minute = 0;
    int second = 0;
    while (in.peek() != JsonToken.END_OBJECT) {
        String name = in.nextName();
        int value = in.nextInt();
        if (YEAR.equals(name)) {
            year = value;
        } else if (MONTH.equals(name)) {
            month = value;
        } else if (DAY_OF_MONTH.equals(name)) {
            dayOfMonth = value;
        } else if (HOUR_OF_DAY.equals(name)) {
            hourOfDay = value;
        } else if (MINUTE.equals(name)) {
            minute = value;
        } else if (SECOND.equals(name)) {
            second = value;
        }
    }
    in.endObject();
    return new GregorianCalendar(year, month, dayOfMonth, hourOfDay, minute, second);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:33,代码来源:TypeAdapters.java

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

示例13: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public Calendar read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
    }
    in.beginObject();
    int year = 0;
    int month = 0;
    int dayOfMonth = 0;
    int hourOfDay = 0;
    int minute = 0;
    int second = 0;
    while (in.peek() != JsonToken.END_OBJECT) {
        String name = in.nextName();
        int value = in.nextInt();
        if ("year".equals(name)) {
            year = value;
        } else if ("month".equals(name)) {
            month = value;
        } else if (DAY_OF_MONTH.equals(name)) {
            dayOfMonth = value;
        } else if (HOUR_OF_DAY.equals(name)) {
            hourOfDay = value;
        } else if ("minute".equals(name)) {
            minute = value;
        } else if (SECOND.equals(name)) {
            second = value;
        }
    }
    in.endObject();
    return new GregorianCalendar(year, month, dayOfMonth, hourOfDay, minute, second);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:33,代码来源:TypeAdapters.java

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

示例15: loadFromReader

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public static List<Record> loadFromReader(Reader reader) throws IOException {
    List<Record> rv = new ArrayList<>();
    JsonReader jsonReader = new JsonReader(reader);
    jsonReader.beginArray();
    while (jsonReader.hasNext()) {
        Map<String, String> stringFields = new HashMap<>();
        Map<String, LocalDateTime> timeFields = new HashMap<>();
        Map<String, List<Double>> doubleListFields = new HashMap<>();

        jsonReader.beginObject();
        while (jsonReader.hasNext()) {
            String key = jsonReader.nextName();
            switch (key) {
                case ALGORITHM_ID:
                case DATASET_ID:
                case MEASUREMENT_METHOD:
                case MEASUREMENT_AUTHOR:
                case CPU_MODEL_NAME:
                case COMMENT:
                case JAVA_RUNTIME_VERSION:
                    stringFields.put(key, jsonReader.nextString());
                    break;
                case MEASUREMENT_TIME:
                    timeFields.put(key, LocalDateTime.parse(jsonReader.nextString()));
                    break;
                case MEASUREMENTS: {
                    List<Double> list = new ArrayList<>();
                    jsonReader.beginArray();
                    while (jsonReader.hasNext()) {
                        list.add(jsonReader.nextDouble());
                    }
                    jsonReader.endArray();
                    doubleListFields.put(MEASUREMENTS, list);
                    break;
                }
                default:
                    throw new IOException("In record description, stream contains JSON name '" + key
                            + "' which is not allowed");
            }
        }
        jsonReader.endObject();

        for (String s : ALL_NAMES) {
            if (!stringFields.containsKey(s) && !timeFields.containsKey(s) && !doubleListFields.containsKey(s)) {
                throw new IOException("In record description, JSON name '" + s + "' is missing");
            }
        }
        rv.add(new Record(stringFields.get(ALGORITHM_ID), stringFields.get(DATASET_ID),
                stringFields.get(MEASUREMENT_METHOD), stringFields.get(MEASUREMENT_AUTHOR),
                timeFields.get(MEASUREMENT_TIME), stringFields.get(CPU_MODEL_NAME),
                stringFields.get(JAVA_RUNTIME_VERSION), doubleListFields.get(MEASUREMENTS),
                stringFields.get(COMMENT)));
    }
    jsonReader.endArray();
    return rv;
}
 
开发者ID:mbuzdalov,项目名称:non-dominated-sorting,代码行数:57,代码来源:Records.java


注:本文中的com.google.gson.stream.JsonReader.nextName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。