Yellow-Dog-Man / JSONSchemas

2 stars 0 forks source link

AnimJ Schema #3

Open stiefeljackal opened 10 months ago

stiefeljackal commented 10 months ago

Since creating an animation with AnimJ requires importing a JSON file (hence the letter "J" at the end of AnimJ), it would be great if that schema was present here as well. You should be able to generate the schema from the class files like you do for the Headless and Client config.

ProbablePrime commented 4 days ago

Looked into this today with the flurry of other activity. One of the problems here is that there are some elements in the Elements.Core base structs that need to be tweaked.

Those elements can't easily be bi-directionally serialized to JSON and that's what the schema generator does as part of its process.

The bi-directional issues are due to multi-dimensional number types(float3, etc), being implemented in a specific way in Elements.Core's type generator. The type generator uses, [JsonObject(MemberSerialization = MemberSerialization.OptIn)] from NewtonSoft, but there is no System.Text.Json equivalent of that.

Which leads to every single property of those types being serialized.

These types are very complicated and so that leads to duplicate JSON Properties, which explodes most of the Json stack.

So we need opt-in support for System.Text.Json...

So some research later:

  1. https://github.com/dotnet/runtime/issues/593
  2. https://github.com/dotnet/runtime/issues/63686
  3. https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/custom-contracts#modifiers

We'll have to write our own JSON Contract Modifier to handle this or find one \o/

ProbablePrime commented 4 days ago

Or of course we just mark the problematic elements with JsonIgnore which is easier!