List of usage examples for com.badlogic.gdx.utils JsonValue set
public void set(boolean value)
From source file:com.esotericsoftware.spine.JsonRollback.java
License:Open Source License
static public void main(String[] args) throws Exception { if (args.length == 0) { System.out.println("Usage: <inputFile> [outputFile]"); System.exit(0);/*from www . j a v a 2 s . co m*/ } JsonValue root = new Json().fromJson(null, new FileHandle(args[0])); // In 3.2 skinnedmesh was renamed to weightedmesh. setValue(root, "skinnedmesh", "skins", "*", "*", "*", "type", "weightedmesh"); // In 3.2 shear was added. delete(root, "animations", "*", "bones", "*", "shear"); // In 3.3 ffd was renamed to deform. rename(root, "ffd", "animations", "*", "deform"); // In 3.3 mesh is now a single type, previously they were skinnedmesh if they had weights. for (JsonValue value : find(root, new Array(), 0, "skins", "*", "*", "*", "type", "mesh")) if (value.parent.get("uvs").size != value.parent.get("vertices").size) value.set("skinnedmesh"); // In 3.3 linkedmesh is now a single type, previously they were linkedweightedmesh if they had weights. for (JsonValue value : find(root, new Array(), 0, "skins", "*", "*", "*", "type", "linkedmesh")) { String slot = value.parent.parent.name.replaceAll("", ""); String skinName = value.parent.getString("skin", "default"); String parentName = value.parent.getString("parent"); if (find(root, new Array(), 0, ("skins~~" + skinName + "~~" + slot + "~~" + parentName + "~~type~~skinnedmesh") .split("~~")).size > 0) value.set("weightedlinkedmesh"); } // In 3.3 bounding boxes can be weighted. for (JsonValue value : find(root, new Array(), 0, "skins", "*", "*", "*", "type", "boundingbox")) if (value.parent.getInt("vertexCount") * 2 != value.parent.get("vertices").size) value.parent.parent.remove(value.parent.name); // In 3.3 paths were added. for (JsonValue value : find(root, new Array(), 0, "skins", "*", "*", "*", "type", "path")) { String attachment = value.parent.name; value.parent.parent.remove(attachment); String slot = value.parent.parent.name; // Also remove path deform timelines. delete(root, "animations", "*", "ffd", "*", slot, attachment); } // In 3.3 IK constraint timelines no longer require bendPositive. for (JsonValue value : find(root, new Array(), 0, "animations", "*", "ik", "*")) for (JsonValue child = value.child; child != null; child = child.next) if (!child.has("bendPositive")) child.addChild("bendPositive", new JsonValue(true)); // In 3.3 transform constraints can have more than 1 bone. for (JsonValue child = root.getChild("transform"); child != null; child = child.next) { JsonValue bones = child.remove("bones"); if (bones != null) child.addChild("bone", new JsonValue(bones.child.asString())); } if (args.length > 1) new FileHandle(args[1]).writeString(root.prettyPrint(OutputType.json, 130), false, "UTF-8"); else System.out.println(root.prettyPrint(OutputType.json, 130)); }
From source file:com.esotericsoftware.spine.JsonRollback.java
License:Open Source License
static void setValue(JsonValue root, String newValue, String... path) { for (JsonValue value : find(root, new Array(), 0, path)) value.set(newValue); }
From source file:es.eucm.gleaner.tracker.format.XAPIFormat.java
License:Apache License
private JsonValue createStatement(String trace) { JsonValue statement = pool.obtain(); statement.setType(ValueType.object); JsonValue actorValue = pool.obtain(); actorValue.setType(ValueType.object); actorValue.setName("actor"); actorValue.child = actor;//from w w w . ja va2 s . c o m statement.child = actorValue; String[] parts = trace.split(","); JsonValue verb = pool.obtain(); verb.setType(ValueType.object); verb.setName("verb"); verb.child = createVerb(parts[1]); actorValue.next = verb; JsonValue activity = pool.obtain(); activity.setType(ValueType.object); activity.setName("object"); activity.child = createActivity(parts); verb.next = activity; JsonValue timeStamp = pool.obtain(); timeStamp.setName("timestamp"); date.setTime(Long.parseLong(parts[0])); timeStamp.set(dateFormat.format(date)); activity.next = timeStamp; if (parts.length > 3) { JsonValue extensions = pool.obtain(); extensions.setType(ValueType.object); extensions.setName("extensions"); extensions.child = pool.obtain(); extensions.child.setType(ValueType.object); extensions.child.setName(EXT_PREFIX + "value"); extensions.child.set(parts[3]); JsonValue result = pool.obtain(); result.setType(ValueType.object); result.setName("result"); result.child = extensions; timeStamp.next = result; } return statement; }
From source file:es.eucm.gleaner.tracker.format.XAPIFormat.java
License:Apache License
private JsonValue createVerb(String event) { JsonValue verb = pool.obtain(); verb.setType(ValueType.object);/*from ww w . java 2s . co m*/ String id; if (C.CHOICE.equals(event)) { id = "choose"; } else if (C.SCREEN.equals(event)) { id = "viewed"; } else if (C.ZONE.equals(event)) { id = "entered"; } else if (C.VAR.equals(event)) { id = "updated"; } else { id = event; } verb.setName("id"); verb.set(VERB_PREFIX + id); return verb; }
From source file:es.eucm.gleaner.tracker.format.XAPIFormat.java
License:Apache License
private JsonValue createActivity(String[] parts) { JsonValue activity = pool.obtain(); activity.setType(ValueType.object);/*from w ww . j av a 2 s .c o m*/ String event = parts[1]; String id; if (C.CHOICE.equals(event)) { id = "choice"; } else if (C.SCREEN.equals(event)) { id = "screen"; } else if (C.ZONE.equals(event)) { id = "zone"; } else if (C.VAR.equals(event)) { id = "variable"; } else { id = event; } activity.setName("id"); activity.set(activityId + id + "/" + parts[2]); return activity; }