Open leg100 opened 7 years ago
How I would go about decoding JSON into arbitrary structs? e.g.:
Poison.decode!(~s([ {"type": "giraffe", "args": {"height": 400, "age": 27}}, {"type": "turtle", "args": {"height": 30, "age": 108}} ]), as: [%type{}???])
Where type is arbitrary but one of a finite number of defined structs, and args are the fields for that struct.
You mean as if the data define the type of struct to be used?
This is the way: https://github.com/devinus/poison/pull/207
How I would go about decoding JSON into arbitrary structs? e.g.:
Where type is arbitrary but one of a finite number of defined structs, and args are the fields for that struct.