return new JsonValue(din.readDouble());
else if (type == 's' || type == 'S')
return new JsonValue(parseString(din, type));
- return null;
+ else if (type == 'a' || type == 'A')
+ return parseData(din, type);
+ else
+ throw new GdxRuntimeException("Unrecognized data type");
}
protected JsonValue parseArray(final DataInputStream din) throws IOException {
return result;
}
+ protected JsonValue parseData(final DataInputStream din, final byte blockType) throws IOException {
+ // FIXME: h/H is currently not following the specs because it lacks strong typed, fixed sized containers,
+ // see: https://github.com/thebuzzmedia/universal-binary-json/issues/27
+ final byte dataType = din.readByte();
+ final long size = blockType == 'A' ? readUInt(din) : (long)readUChar(din);
+ final JsonValue result = new JsonValue(JsonValue.ValueType.array);
+ JsonValue prev = null;
+ for (long i = 0; i < size; i++) {
+ final JsonValue val = parse(din, dataType);
+ if (prev != null) {
+ prev.next = val;
+ result.size++;
+ } else {
+ result.child = val;
+ result.size = 1;
+ }
+ prev = val;
+ }
+ return result;
+ }
+
protected String parseString(final DataInputStream din, final byte type) throws IOException {
return readString(din, (type == 's') ? (long)readUChar(din) : readUInt(din));
}