[libgdx] Use JsonMatcher to parse skeleton JSON.

This commit is contained in:
Nathan Sweet 2025-08-05 20:07:35 -04:00
parent 53fb4bcce4
commit 3dad8462a3
2 changed files with 6 additions and 6 deletions

View File

@ -39,7 +39,7 @@ import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.FloatArray;
import com.badlogic.gdx.utils.IntArray;
import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonMatcher;
import com.badlogic.gdx.utils.JsonValue;
import com.badlogic.gdx.utils.Null;
import com.badlogic.gdx.utils.SerializationException;
@ -125,6 +125,8 @@ import com.esotericsoftware.spine.attachments.VertexAttachment;
public class SkeletonJson extends SkeletonLoader {
private final Array<LinkedMesh> linkedMeshes = new Array(true, 8, LinkedMesh[]::new);
private final JsonMatcher parser = new JsonMatcher();
public SkeletonJson (AttachmentLoader attachmentLoader) {
super(attachmentLoader);
}
@ -136,7 +138,7 @@ public class SkeletonJson extends SkeletonLoader {
public SkeletonData readSkeletonData (FileHandle file) {
if (file == null) throw new IllegalArgumentException("file cannot be null.");
try {
SkeletonData skeletonData = readSkeletonData(new JsonReader().parse(file));
SkeletonData skeletonData = readSkeletonData(parser.parseRoot(file));
skeletonData.name = file.nameWithoutExtension();
return skeletonData;
} catch (Throwable ex) {
@ -147,7 +149,7 @@ public class SkeletonJson extends SkeletonLoader {
public SkeletonData readSkeletonData (InputStream input) {
if (input == null) throw new IllegalArgumentException("dataInput cannot be null.");
try {
return readSkeletonData(new JsonReader().parse(input));
return readSkeletonData(parser.parseRoot(input));
} catch (Throwable ex) {
throw new SerializationException("Error reading JSON skeleton data.", ex);
}

View File

@ -73,9 +73,7 @@ public class JsonRollback {
if (skeleton == null) {
skeleton = new JsonValue(ValueType.object);
skeleton.name = "skeleton";
JsonValue first = root.child;
root.child = skeleton;
skeleton.next = first;
root.addChildFirst(skeleton);
}
JsonValue spine = skeleton.get("spine");
if (spine != null)