List of usage examples for com.badlogic.gdx.utils Json Json
public Json(OutputType outputType)
From source file:com.ray3k.skincomposer.data.ProjectData.java
License:Open Source License
public void save(FileHandle file) { moveImportedFiles(saveFile, file);/*from w ww . j a v a 2 s .c om*/ saveFile = file; putRecentFile(file.path()); Json json = new Json(JsonWriter.OutputType.minimal); json.setUsePrototypes(false); file.writeString(json.prettyPrint(this), false); setChangesSaved(true); }
From source file:com.ray3k.skincomposer.data.ProjectData.java
License:Open Source License
public void load(FileHandle file) { Json json = new Json(JsonWriter.OutputType.minimal); ProjectData instance = json.fromJson(ProjectData.class, file); newProject = instance.newProject;//from w w w . ja v a 2 s . c o m jsonData.set(instance.jsonData); atlasData.set(instance.atlasData); preferences.putAll(instance.preferences); saveFile = file; putRecentFile(file.path()); setLastOpenSavePath(file.parent().path() + "/"); atlasData.atlasCurrent = false; main.getRootTable().produceAtlas(); main.getRootTable().populate(); setChangesSaved(true); }
From source file:io.piotrjastrzebski.dungen.DungeonGenerator.java
License:Apache License
public String toJson(JsonWriter.OutputType outputType, boolean pretty) { Json json = new Json(outputType); StringWriter writer = new StringWriter(); json.setWriter(writer);/* w w w .j a va2 s .c om*/ json.writeObjectStart(); json.writeValue("grid-size", settings.getGridSize()); json.writeArrayStart("rooms"); for (Room room : rooms) { if (room.isUnused()) continue; json.writeObjectStart(); json.writeValue("id", room.id); if (room.isMain) { json.writeValue("type", "main"); } else if (room.isHallway) { json.writeValue("type", "hallway"); } else if (room.isExtra) { json.writeValue("type", "extra"); } json.writeValue("bounds", room.bounds); json.writeObjectEnd(); } json.writeArrayEnd(); json.writeArrayStart("paths"); for (HallwayPath path : paths) { json.writeObjectStart(); json.writeValue("id", path.id); json.writeValue("start-room", path.roomA.id); json.writeValue("end-room", path.roomB.id); json.writeValue("start", path.start); if (path.hasBend) { json.writeValue("mid", path.bend); } json.writeValue("end", path.end); json.writeArrayStart("overlaps"); for (Room room : path.overlap) { json.writeValue(room.id); } json.writeArrayEnd(); json.writeObjectEnd(); } json.writeArrayEnd(); json.writeObjectEnd(); if (pretty) { return json.prettyPrint(writer.toString()); } else { return writer.toString(); } }
From source file:it.alcacoop.backgammon.utils.MatchRecorder.java
License:Open Source License
public void saveJson(String fname) { FileHandle fh = Gdx.files.absolute(fname); Writer writer = fh.writer(false); Json json = new Json(OutputType.json); try {/*from w ww .j av a 2s .c o m*/ writer.write(json.prettyPrint(this)); writer.flush(); writer.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:vault.clockwork.Config.java
License:Open Source License
/** * Load configuration file./*from w w w.ja va 2 s. co m*/ * @param filename File to read. * @param recreate Recreate the configuration file on reading fail. * @return Newly loaded configuration. */ static public Config load(String filename, boolean recreate) { Json json = new Json(JsonWriter.OutputType.javascript); FileHandle file = Gdx.files.local(filename); json.setUsePrototypes(false); // load json configuration file Config cfg = file.exists() ? json.fromJson(Config.class, file) : null; if (cfg == null) { cfg = new Config(); if (recreate) { System.err.println("Config file recreating..."); Config.save(cfg, filename); } } return cfg; }
From source file:vault.clockwork.Config.java
License:Open Source License
/** * Save the configuration to the file.//from w w w . j a va2 s .c o m * @param cfg * @param filename */ static public void save(Config cfg, String filename) { Json json = new Json(JsonWriter.OutputType.javascript); FileHandle file = Gdx.files.local(filename); json.setUsePrototypes(false); // save json configuration file file.writeString(json.prettyPrint(cfg), false); }
From source file:vault.clockwork.editor.PropHolder.java
License:Open Source License
/** * Returns the json parser instance.// w ww . j a va 2 s. co m * @return Newly instanced json coder/decoder. */ private static Json getJson() { Json json = new Json(JsonWriter.OutputType.javascript); json.setUsePrototypes(false); json.setIgnoreUnknownFields(true); return json; }