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

Ability to serialize fields explicitly #1395

Open
jonatino opened this issue Apr 1, 2021 · 0 comments
Open

Ability to serialize fields explicitly #1395

jonatino opened this issue Apr 1, 2021 · 0 comments
Labels

Comments

@jonatino
Copy link

jonatino commented Apr 1, 2021

Sometimes you want to serialize a large class but only serialize 1 or 2 fields within it. It's tedious to have to @Transient dozens of fields in order to only serialize 2. It would be nice if there was a configuration option for @Serializable which only serializes fields that are explicitly tagged with an @Expose annotation (or something similar).

Gson offers this feature.

See new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create() and @Expose

Api could be something similar to

@Serializable(explicit = true)

and

@Expose for the fields we want to serialize or @Explicit.

@jonatino jonatino changed the title Ability to serialize only exposed fields Ability to serialize fields explicitly Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant