List of usage examples for com.badlogic.gdx.utils Json prettyPrint
public String prettyPrint(String json, PrettyPrintSettings settings)
From source file:com.jupiter.europa.EuropaGame.java
License:Open Source License
public void saveSettings() { if (!Files.exists(SETTINGS_FILE)) { try {//from w w w.j a v a2s . c om Files.createDirectories(SETTINGS_FILE.getParent()); } catch (IOException ex) { } } try (BufferedWriter bw = Files.newBufferedWriter(SETTINGS_FILE)) { Json json = new Json(); bw.write(json.prettyPrint(this.settings, PRINT_SETTINGS) + System.lineSeparator()); bw.flush(); } catch (IOException ex) { } }
From source file:com.jupiter.europa.EuropaGame.java
License:Open Source License
private void saveGame() { if (this.save == null) { return;/*from ww w. java 2 s .com*/ } Path savePath = FileLocations.SAVE_DIRECTORY.resolve(this.save.getName() + "." + SaveGame.SAVE_EXTENSION); Json json = new Json(); String text = json.prettyPrint(this.save, PRINT_SETTINGS); if (!Files.exists(FileLocations.SAVE_DIRECTORY)) { try { Files.createDirectories(FileLocations.SAVE_DIRECTORY); } catch (IOException ex) { } } try (BufferedWriter bw = Files.newBufferedWriter(savePath)) { bw.write(text + System.lineSeparator()); bw.flush(); } catch (IOException ex) { } }
From source file:com.libgdx.skin.editor.utils.scene2d.CustomSkin.java
License:Apache License
/** Store all resources in the specified skin JSON file. */ public boolean save(FileHandle skinFile) { StringWriter jsonText = new StringWriter(); Json json = new Json(); json.setWriter(new JsonWriter(jsonText)); // ????? type json.writeObjectStart();/*from w w w . j a va 2 s .co m*/ for (Class<? extends Object> resType : saveResoureTypes) { ObjectMap<String, ? extends Object> typeResources = super.getAll(resType); if (emptyMap(typeResources)) { continue; } // type json.writeObjectStart(resType.getName()); write1ResType(typeResources, resType, json); json.writeObjectEnd(); } json.writeObjectEnd(); PrettyPrintSettings settings = new PrettyPrintSettings(); settings.outputType = OutputType.minimal; settings.singleLineColumns = 50; // ? skinFile.writeString(json.prettyPrint(jsonText.toString(), settings), false); return true; }
From source file:org.matheusdev.util.Config.java
License:Open Source License
public void write() { FileWriter writer = null;/* w w w . j a v a2s . c om*/ try { Json json = new Json(); json.setIgnoreUnknownFields(false); json.setUsePrototypes(false); json.setOutputType(OutputType.javascript); writer = new FileWriter(new File(configfile)); writer.write(json.prettyPrint(toJsonDOM(), 100)); } catch (IOException e) { e.printStackTrace(); } finally { try { if (writer != null) writer.close(); } catch (IOException e) { e.printStackTrace(); } } }