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

Mark the gson-java8-datatype dependency as optional #493

Open
Balf opened this issue May 2, 2024 · 3 comments
Open

Mark the gson-java8-datatype dependency as optional #493

Balf opened this issue May 2, 2024 · 3 comments

Comments

@Balf
Copy link
Collaborator

Balf commented May 2, 2024

Since the Gson dependency itself is marked as optional we should also mark this library as optional.

Balf added a commit that referenced this issue May 2, 2024
@kaqqao
Copy link
Member

kaqqao commented May 2, 2024

It used to be like this, but... people would just add Gson and it would work for a while until they'd use a "wrong" type and things would blow up... So I intentionally left the extra data types as "mandatory" hoping an astute developer would override that manually if they're bothered.
With that said... Perhaps you're right. Maybe it's time to rethink that decision as most people seem to use Jackson anyway (due to it being the default in Spring as well). I'll give it a think.

@Balf
Copy link
Collaborator Author

Balf commented May 5, 2024

I see where you're coming from, but I would still make it optional. We should however make an explicit mention that this library is required when using Gson rather than Jackson. On that note: Is it enough to add the Gson library to a project to use Gson over Jackson, or is additional configuration required?

@kaqqao
Copy link
Member

kaqqao commented May 5, 2024

SPQR first checks for Jackson on the classpath and prefers that if available. If not, it checks for Gson, and uses that.
So additional config is only needed if both libraries are available but Gson is preferred:

generator.withValueMapperFactory(new GsonValueMapperFactory())

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

2 participants