本文整理匯總了Java中com.badlogic.gdx.utils.Json.setOutputType方法的典型用法代碼示例。如果您正苦於以下問題:Java Json.setOutputType方法的具體用法?Java Json.setOutputType怎麽用?Java Json.setOutputType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.utils.Json
的用法示例。
在下文中一共展示了Json.setOutputType方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dataToString
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
/**
* Returns JSON string representation of object.
* <p>
* It using libgdx {@link Json} class.
*
* @param object Any object
* @return JSON string representation of {@code object}
*/
public static String dataToString(Object object)
{
if (isPrimitiveType(object))
return object.toString();
Json json = new Json();
json.setTypeName(null);
json.setQuoteLongValues(true);
json.setIgnoreUnknownFields(true);
json.setOutputType(JsonWriter.OutputType.json);
return json.toJson(object);
}
示例2: mapToJSON
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
/**
* @param map Map, not null
* @return JSON representation of given map
*/
public 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);
}
示例3: modify
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
/**
* Returns modified json data.
*
* @param oldJsonData Old data as json string.
* @return New data as json string
*/
public String modify(String oldJsonData)
{
R oldData = JsonProcessor.process(wantedType, transactionCallback, oldJsonData);
R newData = transactionCallback.run(oldData);
Json json = new Json();
json.setTypeName(null);
json.setQuoteLongValues(true);
json.setIgnoreUnknownFields(true);
json.setOutputType(JsonWriter.OutputType.json);
return json.toJson(newData, wantedType);
}
示例4: wrireReplayData
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
/**
* リプレイデータを書き込む
*
* @param rd
* リプレイデータ
* @param model
* 対象のBMS
* @param lnmode
* LNモード
*/
public void wrireReplayData(ReplayData rd, BMSModel model, int lnmode, int index) {
File replaydir = new File("replay");
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();
}
}
示例5: write
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
public static void write(PlayerConfig player) {
Json json = new Json();
json.setOutputType(JsonWriter.OutputType.json);
Path p = Paths.get("player/" + player.getId() + "/config.json");
try (FileWriter fw = new FileWriter(p.toFile())) {
fw.write(json.prettyPrint(player));
fw.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
示例6: write
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
/**
* コースデータを保存する
*
* @param cd コースデータ
*/
public void write(String name, CourseData cd) {
try {
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();
}
}
示例7: write
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
/**
* 難易度表データをキャッシュする
*
* @param td 難易度表データ
*/
public void write(TableData td) {
try {
Json json = new Json();
json.setElementType(TableData.class, "folder", ArrayList.class);
json.setElementType(TableData.TableFolder.class, "songs", ArrayList.class);
json.setElementType(TableData.class, "course", ArrayList.class);
json.setElementType(CourseData.class, "trophy", ArrayList.class);
json.setOutputType(OutputType.json);
OutputStreamWriter fw = new OutputStreamWriter(new BufferedOutputStream(
new GZIPOutputStream(new FileOutputStream(tabledir + "/" + td.getName() + ".bmt"))), "UTF-8");
fw.write(json.prettyPrint(td));
fw.flush();
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例8: save
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
public void save (FileHandle handle) {
Json json = new Json();
json.setOutputType(OutputType.json);
json.setTypeName(null);
json.setUsePrototypes(false);
json.setIgnoreUnknownFields(true);
json.setOutputType(OutputType.json);
handle.child("project.json").writeString(json.prettyPrint(this), false);
}
示例9: makePrefab
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
/** Makes a String describing the GameObject, usable to create a Prefab
*
* @param object - the GameObject that should be Serialized
* @return the String describing the Prefab */
public static String makePrefab (GameObject object) {
Json json = new Json();
json.setOutputType(OutputType.json);
String temp = json.toJson(object);
int transformStart = ordinalIndexOf(temp, '{', 1);
int firstComponentStart = ordinalIndexOf(temp, '{', 2);
String finalstring = temp.substring(0, transformStart) + temp.substring(firstComponentStart);
return finalstring;
}
示例10: toJson
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
public String toJson()
{
Json j = new Json();
j.setOutputType(OutputType.json);
j.setUsePrototypes(false);
j.setElementType(CGCStats.class, "allGames", CGCStatGame.class);
return j.toJson(this);
}
示例11: commit
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
/**
* ダイアログの項目をconfig.xmlに反映する
*/
public void commit() {
config.setPlayername(players.getValue());
config.setResolution(resolution.getValue());
config.setFullscreen(fullscreen.isSelected());
config.setVsync(vsync.isSelected());
config.setBga(bgaop.getValue());
config.setBgaExpand(bgaexpand.getValue());
config.setBgmpath(bgmpath.getText());
config.setSoundpath(soundpath.getText());
config.setSystemvolume((float) systemvolume.getValue());
config.setKeyvolume((float) keyvolume.getValue());
config.setBgvolume((float) bgvolume.getValue());
config.setBmsroot(bmsroot.getItems().toArray(new String[0]));
config.setUpdatesong(updatesong.isSelected());
config.setTableURL(tableurl.getItems().toArray(new String[0]));
config.setShowhiddennote(showhiddennote.isSelected());
config.setAudioDriver(audio.getValue());
config.setAudioDriverName(audioname.getValue());
config.setMaxFramePerSecond(getValue(maxfps));
config.setAudioDeviceBufferSize(getValue(audiobuffer));
config.setAudioDeviceSimultaneousSources(getValue(audiosim));
config.setAudioFreqOption(audioFreqOption.getValue());
config.setAudioFastForward(audioFastForward.getValue());
config.setJudgealgorithm(JudgeAlgorithm.values()[judgealgorithm.getValue()]);
config.setAutoSaveReplay( new int[]{autosavereplay1.getValue(),autosavereplay2.getValue(),
autosavereplay3.getValue(),autosavereplay4.getValue()});
// jkoc_hack is integer but *.setJKOC needs boolean type
config.setCacheSkinImage(usecim.isSelected());
config.setUseSongInfo(useSongInfo.isSelected());
config.setFolderlamp(folderlamp.isSelected());
config.setInputduration(getValue(inputduration));
config.setScrollDutationLow(getValue(scrolldurationlow));
config.setScrollDutationHigh(getValue(scrolldurationhigh));
commitPlayer();
Json json = new Json();
json.setOutputType(OutputType.json);
try (FileWriter fw = new FileWriter("config.json")) {
fw.write(json.prettyPrint(config));
fw.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
示例12: commitPlayer
import com.badlogic.gdx.utils.Json; //導入方法依賴的package包/類
public void commitPlayer() {
if(player == null) {
return;
}
Path p = Paths.get("player/" + player.getId() + "/config.json");
if(playername.getText().length() > 0) {
player.setName(playername.getText());
}
player.setRandom(scoreop.getValue());
player.setRandom2(scoreop2.getValue());
player.setDoubleoption(doubleop.getValue());
player.setGauge(gaugeop.getValue());
player.setLnmode(lntype.getValue());
player.setFixhispeed(fixhispeed.getValue());
player.setJudgetiming(getValue(judgetiming));
player.setConstant(constant.isSelected());
player.setBpmguide(bpmguide.isSelected());
player.setLegacynote(legacy.isSelected());
player.setJudgewindowrate(getValue(exjudge));
player.setNomine(nomine.isSelected());
player.setMarkprocessednote(markprocessednote.isSelected());
player.setShowjudgearea(judgeregion.isSelected());
player.setTarget(target.getValue());
player.setMisslayerDuration(getValue(misslayertime));
player.setIrname(irname.getValue());
player.setUserid(iruserid.getText());
player.setPassword(irpassword.getText());
player.setIrsend(irsend.getValue());
updateInputConfig();
updatePlayConfig();
skinController.update(player);
Json json = new Json();
json.setOutputType(OutputType.json);
try (FileWriter fw = new FileWriter(p.toFile())) {
fw.write(json.prettyPrint(player));
fw.flush();
} catch (IOException e) {
e.printStackTrace();
}
}