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

Picking gson instance #577

Open
nickarls opened this issue Nov 27, 2022 · 3 comments
Open

Picking gson instance #577

nickarls opened this issue Nov 27, 2022 · 3 comments

Comments

@nickarls
Copy link

The documentation section "Selecting underlying library" mentions how to pick gson but how do you pick a specific instance (e.g. the one with the registered type adapters you need)?

@lukas-krecan
Copy link
Owner

Hi, it's currently not possible. But it should be possible to do something like this for Gson. Feel free to submit PR

@nickarls
Copy link
Author

nickarls commented Nov 27, 2022

It would be handy to have it on API level. something like .withNodeFactory(MyGsonNodeFactory) with a default getGson() in GsonNodeFactory that returns new Gson() could be overridden. Or the GsonNodeFactory could have an abstract getGson() that the default implemention would implements as new Gson(). Could could have different ones for different tests...

(haven't checked if it's that applicable to the other serializers but I would assume that they all set up some context)

@lukas-krecan
Copy link
Owner

Sorry, I forgot about this issue. I will be reluctant to do something like you propose as it would mean making the NodeFactory and Node part of the public API/SPI hindering future refactorings.

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