Skip to content

Feature request: Read already-parsed JSON.Object into struct #308

@jakobnissen

Description

@jakobnissen

I have a package where I need to:

  1. Load a JSON file representing a custom struct
  2. Check a "version" field to check which struct to parse it into: MyStructV1, MyStructV2 etc.
  3. 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?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions