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

Add field parameter on TypeAdapterFactory.create #2481

Open
adgar-shi opened this issue Aug 26, 2023 · 1 comment
Open

Add field parameter on TypeAdapterFactory.create #2481

adgar-shi opened this issue Aug 26, 2023 · 1 comment

Comments

@adgar-shi
Copy link

Problem solved by the feature

same field class on different pojo may need different formate, using @JsonAdapter on field,i have to make a lot of TypeAdapter for different formating. i just want make my own annotation with TypeAdapterFactory resolve that.

Feature description

Alternatives / workarounds

@Marcono1234
Copy link
Collaborator

Adding a new parameter to the create method would be a breaking change, so this is probably not something we can do.

Could you please provide a short code example showing where you would need this and why the current Gson functionality does not work?

What might be possible though is to change how Gson's internal JsonAdapterAnnotationTypeAdapterFactory class creates instances of the type adapter. For example it could also in addition to a no-args constructor search for a constructor with Field parameter and use that one. This is only a basic idea though which just came into my mind. It would have to be discussed if this is really something which can and should be added.
Do you think that could solve your problem?

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

No branches or pull requests

2 participants