How to Add \n to Json properties (or) convert json to pretty Json ?

How- Add-Json-properties-convert-json-pretty-Json-featured
How- Add-Json-properties-convert-json-pretty-Json-blog

Do you want to add the \n to all the properties of your json to convert the json look to pretty json.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
public class NgDevPrettyJson {
public static void main(String[] args){
JsonParser parser = new JsonParser();
JsonObject json = parser.parse(jsonString).getAsJsonObject();
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String prettyJson = gson.toJson(json);
return prettyJson;
}
}
public class NgDevPrettyJson { public static void main(String[] args){ JsonParser parser = new JsonParser(); JsonObject json = parser.parse(jsonString).getAsJsonObject(); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String prettyJson = gson.toJson(json); return prettyJson; } }
public class NgDevPrettyJson {
 public static void main(String[] args){
   JsonParser parser = new JsonParser();
      JsonObject json = parser.parse(jsonString).getAsJsonObject();

      Gson gson = new GsonBuilder().setPrettyPrinting().create();
      String prettyJson = gson.toJson(json);

      return prettyJson;
 }
}

Leave a Reply