Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnimJ Schema #3

Open
stiefeljackal opened this issue Jan 26, 2024 · 2 comments
Open

AnimJ Schema #3

stiefeljackal opened this issue Jan 26, 2024 · 2 comments

Comments

@stiefeljackal
Copy link

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
Copy link
Member

ProbablePrime commented Nov 25, 2024

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. System.Text.Json: How to serialize only certain properties without using JsonIgnoreAttribute dotnet/runtime#593
  2. Developers can customize the JSON serialization contracts of their types dotnet/runtime#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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants