I have a package where I need to:
- Load a JSON file representing a custom struct
- Check a "version" field to check which struct to parse it into:
MyStructV1, MyStructV2 etc.
- Parse the corresponding struct
I can do it in two passes: First parse the file to a lazy JSON3.Object, then get the version field, and then re-parse the same string to a MyStructV2. But that seems wasteful: The same string is parsed twice.
Is there a way to build a MyStruct from a JSON.Object?
I have a package where I need to:
MyStructV1,MyStructV2etc.I can do it in two passes: First parse the file to a lazy
JSON3.Object, then get the version field, and then re-parse the same string to aMyStructV2. But that seems wasteful: The same string is parsed twice.Is there a way to build a
MyStructfrom aJSON.Object?