Java Code Examples for com.badlogic.gdx.utils.Json#setOutputType()
The following examples show how to use
com.badlogic.gdx.utils.Json#setOutputType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayDataAccessor.java From beatoraja with GNU General Public License v3.0 | 6 votes |
/** * リプレイデータを書き込む * * @param rd * リプレイデータ * @param model * 対象のBMS * @param lnmode * LNモード */ public void wrireReplayData(ReplayData rd, BMSModel model, int lnmode, int index) { File replaydir = new File(this.getReplayDataFolder()); if (!replaydir.exists()) { replaydir.mkdirs(); } Json json = new Json(); json.setOutputType(OutputType.json); try { String path = this.getReplayDataFilePath(model, lnmode, index) + ".brd"; OutputStreamWriter fw = new OutputStreamWriter( new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(path))), "UTF-8"); fw.write(json.prettyPrint(rd)); fw.flush(); fw.close(); } catch (IOException e) { e.printStackTrace(); } }
Example 2
Source File: PlayDataAccessor.java From beatoraja with GNU General Public License v3.0 | 6 votes |
/** * コースリプレイデータを書き込む * * @param rd * リプレイデータ * @param hash * 対象のBMSハッシュ群 * @param lnmode * LNモード */ public void wrireReplayData(ReplayData[] rd, String[] hash, boolean ln, int lnmode, int index, CourseData.CourseDataConstraint[] constraint) { Json json = new Json(); json.setOutputType(OutputType.json); try { String path = this.getReplayDataFilePath(hash, ln, lnmode, index, constraint) + ".brd"; OutputStreamWriter fw = new OutputStreamWriter( new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(path))), "UTF-8"); fw.write(json.prettyPrint(rd)); fw.flush(); fw.close(); Logger.getGlobal().info("コースリプレイを保存:" + path); } catch (IOException e) { e.printStackTrace(); } }
Example 3
Source File: CourseDataAccessor.java From beatoraja with GNU General Public License v3.0 | 6 votes |
/** * コースデータを保存する * * @param cd コースデータ */ public void write(String name, CourseData[] cd) { try { for(CourseData c : cd) { c.shrink(); } Json json = new Json(); json.setOutputType(JsonWriter.OutputType.json); OutputStreamWriter fw = new OutputStreamWriter(new BufferedOutputStream( new FileOutputStream(coursedir + "/" + name + ".json")), "UTF-8"); fw.write(json.prettyPrint(cd)); fw.flush(); fw.close(); } catch (IOException e) { e.printStackTrace(); } }
Example 4
Source File: BvbProject.java From talos with Apache License 2.0 | 5 votes |
@Override public String getProjectString() { Json json = new Json(); json.setOutputType(JsonWriter.OutputType.json); String data = json.prettyPrint(bvBAddon.workspace); return data; }
Example 5
Source File: GLTFExporter.java From gdx-gltf with Apache License 2.0 | 5 votes |
private void end(FileHandle file){ root.bufferViews = binManager.views; root.buffers = binManager.flushAllToFiles(file.nameWithoutExtension()); Json json = new Json(); json.setOutputType(OutputType.json); json.setUsePrototypes(true); file.writeString(json.prettyPrint(root), false); reset(); }
Example 6
Source File: Save.java From Unlucky with MIT License | 5 votes |
public Save(Player player, String path) { this.player = player; psave = new PlayerAccessor(); json = new Json(); json.setOutputType(JsonWriter.OutputType.json); json.setUsePrototypes(false); file = Gdx.files.local(path); }
Example 7
Source File: StringGenerator.java From gdx-fireapp with Apache License 2.0 | 5 votes |
public static String dataToString(Object object) { if (isPrimitiveType(object)) return object.toString(); Json json = new Json(); json.setTypeName(null); json.setQuoteLongValues(false); json.setIgnoreUnknownFields(true); json.setOutputType(JsonWriter.OutputType.json); return json.toJson(object); }
Example 8
Source File: MapTransformer.java From gdx-fireapp with Apache License 2.0 | 5 votes |
static String mapToJSON(Map<String, Object> map) { Json json = new Json(); json.setTypeName(null); json.setQuoteLongValues(true); json.setIgnoreUnknownFields(true); json.setOutputType(JsonWriter.OutputType.json); return json.toJson(map, HashMap.class); }
Example 9
Source File: JsonDataModifier.java From gdx-fireapp with Apache License 2.0 | 5 votes |
/** * Returns modified json data. * * @param oldJsonData Old data as json string. * @return New data as json string */ @SuppressWarnings("unchecked") public String modify(String oldJsonData) { T oldData = JsonProcessor.process(wantedType, oldJsonData); T newData = (T) transactionFunction.apply(oldData); Json json = new Json(); json.setTypeName(null); json.setQuoteLongValues(true); json.setIgnoreUnknownFields(true); json.setOutputType(JsonWriter.OutputType.json); return json.toJson(newData, wantedType); }
Example 10
Source File: Config.java From beatoraja with GNU General Public License v3.0 | 5 votes |
public static void write(Config config) { Json json = new Json(); json.setUsePrototypes(false); json.setOutputType(OutputType.json); try (FileWriter writer = new FileWriter(MainController.configpath.toFile())) { writer.write(json.prettyPrint(config)); writer.flush(); } catch (IOException e) { e.printStackTrace(); } }
Example 11
Source File: PlayerConfig.java From beatoraja with GNU General Public License v3.0 | 5 votes |
public static void write(String playerpath, PlayerConfig player) { try (FileWriter writer = new FileWriter(Paths.get(playerpath + "/" + player.getId() + "/config.json").toFile())) { Json json = new Json(); json.setOutputType(JsonWriter.OutputType.json); json.setUsePrototypes(false); writer.write(json.prettyPrint(player)); writer.flush(); } catch (IOException e) { e.printStackTrace(); } }
Example 12
Source File: WorldSerialization.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
public void saveGameState(String filename, boolean screenshot) throws IOException { EngineLogger.debug("SAVING GAME STATE"); if (w.isDisposed()) return; Json json = new BladeJson(w, Mode.STATE); json.setOutputType(OutputType.javascript); json.setSortFields(true); String s = null; if (EngineLogger.debugMode()) s = json.prettyPrint(this); else s = json.toJson(this); Writer writer = EngineAssetManager.getInstance().getUserFile(filename).writer(false, "UTF-8"); try { writer.write(s); writer.flush(); } catch (IOException e) { throw new IOException("ERROR SAVING GAME", e); } finally { writer.close(); } // Save Screenshot if (screenshot) w.takeScreenshot(filename + ".png", SCREENSHOT_DEFAULT_WIDTH); }