public String prettyPrint (Object object) { return prettyPrint(object, 0); }
public String prettyPrint (Object object) { return prettyPrint(object, 0); }
public String prettyPrint (String json) { return prettyPrint(json, 0); }
public String prettyPrint (String json) { return prettyPrint(json, 0); }
public String prettyPrint (Object object, int singleLineColumns) { return prettyPrint(toJson(object), singleLineColumns); }
public String prettyPrint (Object object, PrettyPrintSettings settings) { return prettyPrint(toJson(object), settings); }
public String prettyPrint (Object object, PrettyPrintSettings settings) { return prettyPrint(toJson(object), settings); }
public String prettyPrint (Object object, int singleLineColumns) { return prettyPrint(toJson(object), singleLineColumns); }
private String roundTrip (Object object) { String text = json.toJson(object); System.out.println(text); test(text, object); text = json.prettyPrint(object, 130); test(text, object); return text; }
private void testObjectGraph (TestMapGraph object, String typeName) { Json json = new Json(); json.setTypeName(typeName); json.setUsePrototypes(false); json.setIgnoreUnknownFields(true); json.setOutputType(OutputType.json); String text = json.prettyPrint(object); TestMapGraph object2 = json.fromJson(TestMapGraph.class, text); if (object2.map.size() != object.map.size()) { throw new RuntimeException("Too many items in deserialized json map."); } if (object2.objectMap.size != object.objectMap.size) { throw new RuntimeException("Too many items in deserialized json object map."); } if (object2.arrayMap.size != object.arrayMap.size) { throw new RuntimeException("Too many items in deserialized json map."); } }
public String prettyPrint (String json) { return prettyPrint(json, 0); }
public String prettyPrint (Object object) { return prettyPrint(object, 0); }
public String prettyPrint (Object object, int singleLineColumns) { return prettyPrint(toJson(object), singleLineColumns); }
public String prettyPrint (Object object, PrettyPrintSettings settings) { return prettyPrint(toJson(object), settings); }
public String prettyPrint() { return json.prettyPrint(build()); } }
@Override public void create() { System.out.println("======================"); System.out.println("Reading character.json"); System.out.println("======================"); Json json = new Json(); json.setElementType(Character.class, "items", Item.class); Character character = json.fromJson(Character.class, Gdx.files.internal("data/character.json")); System.out.println(character); System.out.println(); System.out.println("====================="); System.out.println("Serializing character"); System.out.println("====================="); System.out.println(json.prettyPrint(json.toJson(character))); Gdx.app.exit(); } }
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); } } }
public void saveModel(String chapterId) throws IOException { EngineLogger.debug("SAVING GAME MODEL"); if (w.isDisposed()) return; Json json = new BladeJson(w, Mode.MODEL); json.setOutputType(OutputType.javascript); String s = null; if (EngineLogger.debugMode()) s = json.prettyPrint(this); else s = json.toJson(this); Writer w = EngineAssetManager.getInstance().getModelFile(chapterId + EngineAssetManager.CHAPTER_EXT) .writer(false, "UTF-8"); try { w.write(s); w.flush(); } catch (IOException e) { throw new IOException("ERROR SAVING MODEL", e); } finally { w.close(); } }
public void save(Writer writer, SaveFileFormat save) { try { referenceTracker.inspectTypes(world); referenceTracker.preWrite(save); save.archetypes = new ArchetypeMapper(world, save.entities); componentCollector.preWrite(save); entitySerializer.serializationState = save; transmuterEntrySerializer.identifiers = save.componentIdentifiers; entitySerializer.archetypeMapper = new ArchetypeMapper(world, save.entities); entitySerializer.archetypeMapper.serializationState = save; save.componentIdentifiers.build(); if (prettyPrint) { writer.append(json.prettyPrint(save)); writer.flush(); } else { json.toJson(save, writer); } } catch (IOException e) { throw new SerializationException(e); } }
public void saveWorldDesc(FileHandle file) throws IOException { float scale = EngineAssetManager.getInstance().getScale(); Json json = new BladeJson(w, Mode.MODEL); json.setOutputType(OutputType.javascript); json.setWriter(new StringWriter()); json.writeObjectStart(); json.writeValue("width", w.getWidth() / scale); json.writeValue("height", w.getHeight() / scale); json.writeValue("initChapter", w.getInitChapter()); w.getVerbManager().write(json); json.writeObjectEnd(); String s = null; if (EngineLogger.debugMode()) s = json.prettyPrint(json.getWriter().getWriter().toString()); else s = json.getWriter().getWriter().toString(); Writer w = file.writer(false, "UTF-8"); w.write(s); w.close(); }