static public void main (String[] args) throws Exception { Settings settings = null; String input = null, output = null, packFileName = "pack.atlas"; switch (args.length) { case 4: settings = new Json().fromJson(Settings.class, new FileReader(args[3])); case 3: packFileName = args[2]; case 2: output = args[1]; case 1: input = args[0]; break; default: System.out.println("Usage: inputDir [outputDir] [packFileName] [settingsFileName]"); System.exit(0); } if (output == null) { File inputFile = new File(input); output = new File(inputFile.getParentFile(), inputFile.getName() + "-packed").getAbsolutePath(); } if (settings == null) settings = new Settings(); process(settings, input, output, packFileName); } }
static public void main (String[] args) throws Exception { Settings settings = null; String input = null, output = null, packFileName = "pack.atlas"; switch (args.length) { case 4: settings = new Json().fromJson(Settings.class, new FileReader(args[3])); case 3: packFileName = args[2]; case 2: output = args[1]; case 1: input = args[0]; break; default: System.out.println("Usage: inputDir [outputDir] [packFileName] [settingsFileName]"); System.exit(0); } if (output == null) { File inputFile = new File(input); output = new File(inputFile.getParentFile(), inputFile.getName() + "-packed").getAbsolutePath(); } if (settings == null) settings = new Settings(); process(settings, input, output, packFileName); } }
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."); } }
/** Saves the effect to the given file contained in the passed in parameter. */ public void save (ParticleEffect effect, ParticleEffectSaveParameter parameter) throws IOException { ResourceData<ParticleEffect> data = new ResourceData<ParticleEffect>(effect); // effect assets effect.save(parameter.manager, data); // Batches configurations if (parameter.batches != null) { for (ParticleBatch<?> batch : parameter.batches) { boolean save = false; for (ParticleController controller : effect.getControllers()) { if (controller.renderer.isCompatible(batch)) { save = true; break; } } if (save) batch.save(parameter.manager, data); } } // save Json json = new Json(); json.toJson(data, parameter.file); }
/** Saves the effect to the given file contained in the passed in parameter. */ public void save (ParticleEffect effect, ParticleEffectSaveParameter parameter) throws IOException { ResourceData<ParticleEffect> data = new ResourceData<ParticleEffect>(effect); // effect assets effect.save(parameter.manager, data); // Batches configurations if (parameter.batches != null) { for (ParticleBatch<?> batch : parameter.batches) { boolean save = false; for (ParticleController controller : effect.getControllers()) { if (controller.renderer.isCompatible(batch)) { save = true; break; } } if (save) batch.save(parameter.manager, data); } } // save Json json = new Json(); json.toJson(data, parameter.file); }
@Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, ParticleEffectLoadParameter parameter) { Json json = new Json(); ResourceData<ParticleEffect> data = json.fromJson(ResourceData.class, file); Array<AssetData> assets = null; synchronized (items) { ObjectMap.Entry<String, ResourceData<ParticleEffect>> entry = new ObjectMap.Entry<String, ResourceData<ParticleEffect>>(); entry.key = fileName; entry.value = data; items.add(entry); assets = data.getAssets(); } Array<AssetDescriptor> descriptors = new Array<AssetDescriptor>(); for (AssetData<?> assetData : assets) { // If the asset doesn't exist try to load it from loading effect directory if (!resolve(assetData.filename).exists()) { assetData.filename = file.parent().child(Gdx.files.internal(assetData.filename).name()).path(); } if (assetData.type == ParticleEffect.class) { descriptors.add(new AssetDescriptor(assetData.filename, assetData.type, parameter)); } else descriptors.add(new AssetDescriptor(assetData.filename, assetData.type)); } return descriptors; }
@Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, ParticleEffectLoadParameter parameter) { Json json = new Json(); ResourceData<ParticleEffect> data = json.fromJson(ResourceData.class, file); Array<AssetData> assets = null; synchronized (items) { ObjectMap.Entry<String, ResourceData<ParticleEffect>> entry = new ObjectMap.Entry<String, ResourceData<ParticleEffect>>(); entry.key = fileName; entry.value = data; items.add(entry); assets = data.getAssets(); } Array<AssetDescriptor> descriptors = new Array<AssetDescriptor>(); for (AssetData<?> assetData : assets) { // If the asset doesn't exist try to load it from loading effect directory if (!resolve(assetData.filename).exists()) { assetData.filename = file.parent().child(Gdx.files.internal(assetData.filename).name()).path(); } if (assetData.type == ParticleEffect.class) { descriptors.add(new AssetDescriptor(assetData.filename, assetData.type, parameter)); } else descriptors.add(new AssetDescriptor(assetData.filename, assetData.type)); } return descriptors; }
println("Copied field by field: " + fieldCopy); Json json = new Json(); String jsonString = json.toJson(fromCopyConstructor); Vector2 fromJson = json.fromJson(Vector2.class, jsonString);
public void create () { json = new Json();
new Json(){ @Override protected void onPostExecute(String result2) { //use string result as you want here } }.execute("http://127.0.0.1/web/test.php");
public ActionResult TestWithActionResult(string id) { return new Json("some string"); }
public void setAction(Action a) { action = a; Json json = new Json(); StringWriter buffer = new StringWriter(); json.setWriter(buffer); ActionUtils.writeJson(a, json); serializedAction = buffer.toString(); }
private static AseFormat fromJson(FileHandle jsonFile) { final Json json = new Json(); json.setIgnoreUnknownFields(true); return json.fromJson(AseFormat.class, jsonFile); }
private static AseFormat fromJson(FileHandle jsonFile) { final Json json = new Json(); json.setIgnoreUnknownFields(true); return json.fromJson(AseFormat.class, jsonFile); }
public Action getAction() { if(action == null) { Json json = new Json(); JsonValue root = new JsonReader().parse(serializedAction); action = ActionUtils.readJson(w, json, root); } return action; } }
@Initiate public void initialize() { json = new Json(); json.setSerializer(VersionData.class, new VersionData.Serializer()); }
@Override public String serializeState() { StringWriter buffer = new StringWriter(); try { Json json = new Json(); json.setWriter(new JsonWriter(buffer)); json.writeObjectStart(); json.writeValue("level", level); json.writeValue("removeGamma", removeGamma); json.writeObjectEnd(); return buffer.toString(); } finally { StreamUtils.closeQuietly(buffer); } }
@Override public String serializeState() { StringWriter buffer = new StringWriter(); try { Json json = new Json(); json.setWriter(new JsonWriter(buffer)); json.writeObjectStart(); json.writeValue("encoding", encoding.name()); json.writeValue("quality", quality); json.writeObjectEnd(); return buffer.toString(); } finally { StreamUtils.closeQuietly(buffer); } }
@Initiate void initialize() { json = new Json(); json.setSerializer(ScaleFactorModel.class, new ScaleFactorJsonSerializer()); json.setSerializer(InputFile.class, inputFileSerializer = new InputFileSerializer()); }
public GitHubApiHelper() throws IOException { apiSecret = resolveApiKey(); authCallbackHandler = new AuthCallbackHandler(); // Request access to interact with public repos. apiService = new ServiceBuilder("466a909f95b8e2789a5e") .apiSecret(apiSecret) .state("authorized") .scope("public_repo") // Request access to interact with public repos. .callback(AuthCallbackHandler.CALLBACK_URL) .build(GitHubApi.instance()); json = new Json(JsonWriter.OutputType.json); }