Currently I am using the Google's Gson class to parse incoming Ajax JSON strings into Java pojos, as part of the doGet/doPost tasks. I instantiate a new Gson object the usual out from the JSON string the usual way:
JsonObj jsonObj = new Gson().fromJson(jsonStr, jsonObj.class);
The doubt is if I should instantiate a shared gson object in the servlet initialization to avoid doing new Gson()
in every servlet doGet/doPost call.
Here Instantiate a new instance of GSON for every serialization? I've learnt that Gson is not a singleton and that some customization is possible with GsonBuilder, but this is not my case. I am worried about the multithreading behavior of the shared Gson object.