Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoding to arbitrary structs #124

Open
leg100 opened this issue Mar 20, 2017 · 2 comments
Open

Decoding to arbitrary structs #124

leg100 opened this issue Mar 20, 2017 · 2 comments

Comments

@leg100
Copy link

leg100 commented Mar 20, 2017

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.

@roehst
Copy link

roehst commented Sep 19, 2018

You mean as if the data define the type of struct to be used?

@rauann
Copy link
Contributor

rauann commented Apr 25, 2022

This is the way: #207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants