holopy3/Assets/UniGLTF/UniJSON
Lena Biresch 490ef558ef CleanUp
2021-01-28 13:07:52 +01:00
..
Editor CleanUp 2021-01-28 13:07:52 +01:00
Scripts CleanUp 2021-01-28 13:07:52 +01:00
Editor.meta CleanUp 2021-01-28 13:07:52 +01:00
LICENSE CleanUp 2021-01-28 13:07:52 +01:00
LICENSE.meta CleanUp 2021-01-28 13:07:52 +01:00
README.md CleanUp 2021-01-28 13:07:52 +01:00
README.md.meta CleanUp 2021-01-28 13:07:52 +01:00
Scripts.meta CleanUp 2021-01-28 13:07:52 +01:00

UniJSON

JSON serializer and deserializer and schema utilities for Unity(.Net3.5)

JSON

JSON Schema

JSON Patch

ToDo

  • anyOf to enum
  • string.pattern
  • enum.values
  • array.items
  • object.required
  • object.dependencies
  • object.additionalProperties
  • default value

Example

[Serializable]
public class glTFSparseIndices
{
    [JsonSchema(Minimum = 0)]
    public int bufferView;

    [JsonSchema(Minimum = 0)]
    public int byteOffset;

    [JsonSchema(EnumSerializationType = EnumSerializationType.AsInt)]
    public glComponentType componentType;

    // empty schemas
    public object extensions;
    public object extras;
}


[Test]
public void AccessorSparseIndices()
{
    // from JSON schema
    var path = Path.GetFullPath(Application.dataPath + "/../glTF/specification/2.0/schema");
    var SchemaDir = new FileSystemAccessor(path);
    var fromSchema = JsonSchema.ParseFromPath(SchemaDir.Get("accessor.sparse.indices.schema.json"));

    // from C# type definition
    var fromClass = JsonSchema.FromType<glTFSparseIndices>();

    Assert.AreEqual(fromSchema, fromClass);
}