Java Code Examples for com.badlogic.gdx.utils.Json#prettyPrint()

The following examples show how to use com.badlogic.gdx.utils.Json#prettyPrint() . 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: Recorder.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public void save() {

		Json json = new Json();

		// String s = json.prettyPrint(list);
		String s = json.toJson(list, ArrayList.class, TimeVerb.class);
		s = json.prettyPrint(s);

		Writer w = EngineAssetManager.getInstance().getUserFile(fileName + RECORD_EXT).writer(false, "UTF-8");

		try {
			w.write(s);
			w.close();
		} catch (IOException e) {
			EngineLogger.error("ERROR SAVING RECORD", e);
		}
	}
 
Example 2
Source File: BvbProject.java    From talos with Apache License 2.0 5 votes vote down vote up
@Override
public String getProjectString() {
    Json json = new Json();
    json.setOutputType(JsonWriter.OutputType.json);
    String data = json.prettyPrint(bvBAddon.workspace);
    return data;
}
 
Example 3
Source File: WorldSerialization.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
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);
}