Nesting additional data in json object #1328
Labels
state: needs more info
the author of the issue needs to provide more details
state: stale
the issue has not been updated in a while and will be closed automatically soon unless it is updated
v3.3.0
gcc 7.3.0
Inexperienced C++ user here, so I may just be overlooking something.
My goal is to nest additional, context specific data inside a json object, such that when a json reference is returned by a member function, the data is passed to the child.
To be more specific, I have a Scene class that is deserializing a json file to instantiate a prefab. Within this prefab json file, there are IDs that can be locally referenced, but when the Scene is deserializing it, it generates a new ID for each ID in the json, so that if a prefab is instantiated multiple times, each instance won't have the same IDs.
So in the preceding example, 0 and 1 are the local IDs, and this deserialization "context" would create a map of local IDs to real IDs that would look something like...
The Scene doesn't know how to deserialize Hierarchy components, so it calls deserialize on each component, passing in the data that it needs to deserialize itself, such as...
But now the Hierarchy component knows nothing of the 'real ID' that "1" maps to.
I tried creating a class extending json, and storing this map in there as a shared_ptr, and wrapping all of the accessors, but quickly realized this wouldn't work because they return references to json objects, and I can't return a reference to my type.
The end goal is to allow the deserialization for the Hierarchy component to look something along the lines of...
Which would call a specialized template on the json object for optional and vector that would look in the ID map, and return an Entity with the context specific ID.
The only thing I can think of is modifying the entire basic_json class to hold a void* or something, that it passes down to each child, and then my wrapper would utilize that void* to store the context specific data.
The text was updated successfully, but these errors were encountered: