Answer the question
In order to leave comments, you need to log in
Is it possible to use Gson as a singleton?
Hello! In all the examples and codes I have seen, the gson object is created directly at the serialization site.
Can it be used as a singleton? To not create every time?
Maybe there are some problems with multithreading, so it needs to be created in the place of direct use?
Answer the question
In order to leave comments, you need to log in
Can. It does not store internal state. Just make the singleton thread-safe.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question