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

Feature Request: automatic serialization / deserialization of S7 classes #504

Open
natemcintosh opened this issue Nov 22, 2024 · 0 comments

Comments

@natemcintosh
Copy link

The general idea

Something similar to go's json.Marshall() and json.Unmarshall(), which allow (mostly) automatic conversion to and from JSON.

Use cases

  • Configuration objects (my use case). You have a model that is complex enough to require a number of input parameters, some of them nested. Maybe you started with a list, but it's getting hard to keep track of all necessary fields, so you move to a class. Would be extremely handy to be able to read/write configurations directly to/from files (JSON, YAML, TOML, etc.)
  • Accepting structured data from a web API directly into a class.
  • Many non-web systems produce structured data, and it would be very convenient to be able to ingest their data directly into a class.

Issues with this suggestion

  • Seems like a minefield of edge cases
  • Lots of hard choices on how opinionated should such a system should be:
    • automatic type conversion, e.g. should it automatically convert a string to a date?
    • nested cases, e.g. how do you manage an Address class inside a Person class.
    • case matching, e.g. called address in JSON, but your property/class name is Address

Feel free to say "won't do" and close; I'm aware this is a big ask 😅.

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

1 participant