Open msusag opened 1 month ago
I have't been able to reproduce this.
Are you sure you're passing a proper json nodes document to the extras?
The only way I can think of to reproduce your issue is to pass the entire json as a string inside a Json Value Node
Hi, and thanks for developing this nice GLTF library for .NET!
When storing JSON information (or any other information with quotation and other special characters), in the mesh.Extras element, the special characters in the JSON data is escaped and stored in the output .glb files.
In 1.0.0-alpha0030, special characters were not escaped. In that previous version we were able to store for example
{"key":123456}
directly in the output glb files without any escaping. Our reader accepts data in this format only.With the new System.Text.Json serializer used in the current latest version 1.0.0-alpha0031, characters are escaped (due to System.Text.Json default encoder settings.
So the data stored in the .glb file is now
{\u0022key\u0022:123456}
We have found no way with SharpGLTF 1.0.0-alpha0031 be able to override the json encoder settings, to make it store quotes in text without escaping, in output .glb files.
We understand the reasons for escaping is to avoid potential security issues, but in this case the added information is system controlled, not provided by end users.
Would it be possible to override the jsonSerializerOptions and encoderSettings for the JSONEXTRAS (System.Text.Json) in https://github.com/vpenades/SharpGLTF/blob/master/src/SharpGLTF.Core/Schema2/gltf.ExtraProperties.cs#L19
It should be possible to use custom JsonSerializerOptions and encoderSettings for the JSONEXTRAS instance, as documented in https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/character-encoding#serialize-specific-characters