/** * Returns the {@link Json} service. */ public static Json json() { return platform.json(); }
protected Json json () { return game().plat.json(); } protected Log log () { return game().plat.log(); }
public RFuture<Library> apply (String text) { return decodeLibrary(plat.json().parse(text), baseDir, asyncLoader); } });
/** * @return a String representation of the given Json */ public static String toString (Platform plat, Json.Object json, boolean verbose) { Json.Writer writer = plat.json().newWriter().useVerboseFormat(verbose); writer.object(); json.write(writer); writer.end(); return writer.write(); }
/** * Loads a JSON encoded library synchronously. * @param baseDir The base directory, containing library.json and texture atlases. */ public static Library loadLibrarySync (final Platform plat, String baseDir) throws Exception { final ImageLoader syncLoader = new ImageLoader() { @Override public Image load (String path) { return plat.assets().getImageSync(path); } }; String text = plat.assets().getTextSync(baseDir + "/library.json"); Try<Library> result = decodeLibrary(plat.json().parse(text), baseDir, syncLoader).result(); if (result.isSuccess()) return result.get(); Throwable error = result.getFailure(); if (error instanceof Exception) throw (Exception)error; else throw new RuntimeException(error); }