Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Prepare Interview

Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Google Gson Interview Questions and Answers

Ques. How to provide Pretty Printing for JSON Output Format?
The default JSON output that is provide by Gson is a compact JSON format. This means that there will not be any white-space in the output JSON structure. To generate a more readable and pretty looking JSON use setPrettyPrinting() in GsonBuilder.

Gson gson = new GsonBuilder().setPrettyPrinting().create();
String jsonOutput = gson.toJson(employee);

  "id": 1,
  "firstName": "Lokesh",
  "lastName": "Gupta",
  "roles": [
  "birthDate": "17/06/2014"
Is it helpful? Yes No

Most helpful rated by users:

©2020 WithoutBook