Google%20Gson%20Interview%20Questions%20and%20Answers
Question: What are the two ways to create Gson objects?Answer:Gson object can be created in two ways. First way gives you a quick Gson object ready for faster coding, while second way uses GsonBuilder to build a more sophisticated Gson object. //First way to create a Gson object for faster coding Gson gson = new Gson(); //Second way to create a Gson object using GsonBuilder Gson gson = new GsonBuilder() .disableHtmlEscaping() .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE) .setPrettyPrinting() .serializeNulls() .create();
When using GsonBuilder, there are plenty of other useful options you can provide to Gson object. |
Is it helpful?
Yes
No
Most helpful rated by users:
- What is Google-Gson?
- How to convert Java objects to JSON format?
- What are the two ways to create Gson objects?
- What is Instance Creator? Why and when do we require this?
- How to custom Serialization and De-serialization in Gson?