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


Java JsonReader.close方法代码示例

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


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

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

示例2: setup

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
/**
 * Setup logic tests.
 * @throws IOException On File IO errors.
 */
@Before
public void setup() throws IOException {
  person = new Person(0L);
  time = System.currentTimeMillis();

  Path modulesFolder = Paths.get("src/test/resources/generic");
  Path logicFile = modulesFolder.resolve("logic.json");
  JsonReader reader = new JsonReader(new FileReader(logicFile.toString()));
  tests = new JsonParser().parse(reader).getAsJsonObject();
  reader.close();
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:16,代码来源:LogicTest.java

示例3: getModule

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
private static Module getModule(String name) {
  try {
    Path modulesFolder = Paths.get("src/test/resources/generic");
    Path logicFile = modulesFolder.resolve(name);
    JsonReader reader = new JsonReader(new FileReader(logicFile.toString()));
    JsonObject jsonModule = new JsonParser().parse(reader).getAsJsonObject();
    reader.close();

    return new Module(jsonModule, false);
  } catch (Exception e) {
    // if anything breaks, we can't fix it. throw a RuntimeException for simplicity
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:16,代码来源:StateTest.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: AItems

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
private AItems() {
    Type itemType = new TypeToken<List<FEItem>>() {}.getType();

    try {
        Gson gson = new Gson();
        JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
                .getResourceAsStream("data/json/AwakeningItems.json"), "UTF-8")));
        items = gson.fromJson(reader, itemType);
        reader.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:thane98,项目名称:3DSFE-Randomizer,代码行数:14,代码来源:AItems.java

示例6: getRequest

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public <P> P getRequest(Type requestType) throws IOException {
	if (iGson == null) iGson = createGson();
	JsonReader reader = new JsonReader(iRequest.getReader());
	try {
		return iGson.fromJson(reader, requestType);
	} finally {
		reader.close();
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:11,代码来源:JsonApiHelper.java

示例7: AChapters

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
private AChapters() {
    Type chapterType = new TypeToken<List<Chapter>>() {}.getType();

    try {
        Gson gson = new Gson();
        JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
                .getResourceAsStream("data/json/AwakeningChapters.json"), "UTF-8")));
        chapters = gson.fromJson(reader, chapterType);
        reader.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:thane98,项目名称:3DSFE-Randomizer,代码行数:14,代码来源:AChapters.java

示例8: AJobs

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
private AJobs() {
    Type jobType = new TypeToken<List<Job>>() {}.getType();
    try {
        Gson gson = new Gson();
        JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
                .getResourceAsStream("data/json/AwakeningClasses.json"), "UTF-8")));
        jobs = gson.fromJson(reader, jobType);
        reader.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:thane98,项目名称:3DSFE-Randomizer,代码行数:13,代码来源:AJobs.java

示例9: FatesSkills

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
private FatesSkills() {
    try {
        // Parse skills from JSON.
        Type skillType = new TypeToken<List<Skill>>() {}.getType();
        Gson gson = new Gson();
        JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
                .getResourceAsStream("data/json/FatesSkills.json"), "UTF-8")));
        skills = gson.fromJson(reader, skillType);
        reader.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:thane98,项目名称:3DSFE-Randomizer,代码行数:14,代码来源:FatesSkills.java

示例10: decode

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
private Object decode(String json)
        throws IOException {
    JsonReader reader = new JsonReader(new StringReader(json));

    try {
        reader.beginObject();

        Class<?> type = Class.forName(reader.nextName());
        return gson.fromJson(reader, type);
    } catch(ClassNotFoundException e) {
        throw new RuntimeException(e);
    } finally {
        reader.close();
    }
}
 
开发者ID:Zhuinden,项目名称:simple-stack,代码行数:16,代码来源:GsonParceler.java

示例11: FatesChapters

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
private FatesChapters() {
    try {
        Type chapterType = new TypeToken<List<Chapter>>() {}.getType();
        Gson gson = new Gson();
        JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
                .getResourceAsStream("data/json/FatesChapters.json"), "UTF-8")));
        chapters = gson.fromJson(reader, chapterType);
        reader.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:thane98,项目名称:3DSFE-Randomizer,代码行数:13,代码来源:FatesChapters.java

示例12: FatesItems

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
private FatesItems() {
    try {
        Type itemType = new TypeToken<List<FEItem>>() {}.getType();
        Gson gson = new Gson();
        JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
                .getResourceAsStream("data/json/FatesItems.json"), "UTF-8")));
        items = gson.fromJson(reader, itemType);
        reader.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:thane98,项目名称:3DSFE-Randomizer,代码行数:13,代码来源:FatesItems.java

示例13: randomizeWithSettings

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@FXML
private void randomizeWithSettings() {
    FileChooser chooser = new FileChooser();
    chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(
            "JSON Files (*.json)", "*.json"));
    File file = chooser.showOpenDialog(Gui.getInstance().getMainStage());
    try {
        Type type = new TypeToken<SettingsWrapper>() {
        }.getType();
        Gson gson = new Gson();
        JsonReader reader = new JsonReader(new BufferedReader(new FileReader(file)));
        SettingsWrapper wrapper = gson.fromJson(reader, type);
        reader.close();
        FatesGui.getInstance().setSelectedOptions(wrapper.getGui().getSelectedOptions());
        FatesGui.getInstance().setSelectedPaths(wrapper.getGui().getSelectedPaths());
        FatesGui.getInstance().setSelectedItems(wrapper.getGui().getSelectedItems());
        FatesGui.getInstance().setSelectedSkills(wrapper.getGui().getSelectedSkills());
        if (wrapper.getGui().getSelectedPaths()[0] && !FatesFiles.getInstance().isBirthrightVerified()) {
            throwUnverifiedPathDialog();
            return;
        }
        if (wrapper.getGui().getSelectedPaths()[1] && !FatesFiles.getInstance().isConquestVerified()) {
            throwUnverifiedPathDialog();
            return;
        }
        if (wrapper.getGui().getSelectedPaths()[2] && !FatesFiles.getInstance().isRevelationVerified()) {
            throwUnverifiedPathDialog();
            return;
        }
        List<FatesCharacter> selectedCharacters = wrapper.getCharacters();
        loadCodeBin();
        FatesHub hub = new FatesHub();
        hub.randomizeWithSettings(selectedCharacters);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:thane98,项目名称:3DSFE-Randomizer,代码行数:38,代码来源:FatesOptions.java

示例14: gson

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Benchmark
public void gson(Blackhole bh) throws Exception {
	JsonReader reader = new JsonReader(new CharArrayReader(chars));
	while (true) {
		JsonToken token = reader.peek();
		switch (token) {
		case BEGIN_ARRAY:
			reader.beginArray();
			break;
		case END_ARRAY:
			reader.endArray();
			break;
		case BEGIN_OBJECT:
			reader.beginObject();
			break;
		case END_OBJECT:
			reader.endObject();
			break;
		case NAME:
			reader.nextName();
			break;
		case STRING:
			reader.nextString();
			break;
		case NUMBER:
			reader.nextString();
			break;
		case BOOLEAN:
			reader.nextBoolean();
			break;
		case NULL:
			reader.nextNull();
			break;
		case END_DOCUMENT:
			reader.close();
			return;
		}
	}
}
 
开发者ID:httpdigest,项目名称:ftljson,代码行数:40,代码来源:B.java

示例15: loadSchedulesFromScheduler

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
private static List<Schedule> loadSchedulesFromScheduler() throws IOException {
    FileReader fileReader = new FileReader(SCHEDULER_RESOURCE_PATH + SCHEDULE_FILENAME);
    JsonReader reader = new JsonReader(fileReader);
    List<Schedule> schedules = gson.fromJson(reader, new TypeToken<List<Schedule>>() {
    }.getType());
    reader.close();
    fileReader.close();
    return schedules;
}
 
开发者ID:cocolocomoco21,项目名称:ULCRS,代码行数:10,代码来源:ORToolsScheduler.java


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