本文整理了Java中com.badlogic.gdx.utils.Json.<init>()
方法的一些代码示例,展示了Json.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.<init>()
方法的具体详情如下:
包路径:com.badlogic.gdx.utils.Json
类名称:Json
方法名:<init>
暂无
代码示例来源:origin: libgdx/libgdx
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);
}
}
代码示例来源:origin: libgdx/libgdx
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);
}
}
代码示例来源:origin: libgdx/libgdx
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.");
}
}
代码示例来源:origin: libgdx/libgdx
/** 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);
}
代码示例来源:origin: libgdx/libgdx
/** 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);
}
代码示例来源:origin: libgdx/libgdx
@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;
}
代码示例来源:origin: libgdx/libgdx
@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;
}
代码示例来源:origin: libgdx/libgdx
println("Copied field by field: " + fieldCopy);
Json json = new Json();
String jsonString = json.toJson(fromCopyConstructor);
Vector2 fromJson = json.fromJson(Vector2.class, jsonString);
代码示例来源:origin: libgdx/libgdx
public void create () {
json = new Json();
代码示例来源:origin: stackoverflow.com
new Json(){
@Override
protected void onPostExecute(String result2) {
//use string result as you want here
}
}.execute("http://127.0.0.1/web/test.php");
代码示例来源:origin: stackoverflow.com
public ActionResult TestWithActionResult(string id)
{
return new Json("some string");
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
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();
}
代码示例来源:origin: net.mostlyoriginal.artemis-odb/contrib-jam
private static AseFormat fromJson(FileHandle jsonFile) {
final Json json = new Json();
json.setIgnoreUnknownFields(true);
return json.fromJson(AseFormat.class, jsonFile);
}
代码示例来源:origin: DaanVanYperen/artemis-odb-contrib
private static AseFormat fromJson(FileHandle jsonFile) {
final Json json = new Json();
json.setIgnoreUnknownFields(true);
return json.fromJson(AseFormat.class, jsonFile);
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
public Action getAction() {
if(action == null) {
Json json = new Json();
JsonValue root = new JsonReader().parse(serializedAction);
action = ActionUtils.readJson(w, json, root);
}
return action;
}
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Initiate
public void initialize() {
json = new Json();
json.setSerializer(VersionData.class, new VersionData.Serializer());
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@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);
}
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@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);
}
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Initiate void initialize() {
json = new Json();
json.setSerializer(ScaleFactorModel.class, new ScaleFactorJsonSerializer());
json.setSerializer(InputFile.class, inputFileSerializer = new InputFileSerializer());
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
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);
}
内容来源于网络,如有侵权,请联系作者删除!