syoyo/tinygltf

Empty scenes are wrongly serialized as null

ptc-tgamper opened this issue · 2 comments

Describe the issue

Empty scenes are incorrectly serialized as json null. They should be serialized as empty json objects instead.

To Reproduce

tinygltf::Model m;
m.scenes.push_back({});
tinygltf::TinyGLTF ctx;
std::stringstream os;
ctx.WriteGltfSceneToStream(&m, os, false, false);

The output is as follows:
{"asset":{"version":"2.0"},"scenes":[null]}

  • OS: ALL
  • Compiler, compiler version, compile options: ALL

Expected behaviour

Empty GLTF scenes shall be serialized as empty JSON objects

syoyo commented

Yes, as commented #457 (comment), I think we should create empty objects for other glTF scene items(e.g. meshes) also.

FYI, It looks glTF spec totally prohibits null JSON object
(No null keyword in https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html)

Yeah, I am doing this in small, easy digestible pieces.