當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。