List of usage examples for com.google.gson GsonBuilder setPrettyPrinting
public GsonBuilder setPrettyPrinting()
From source file:com.google.enterprise.adaptor.secmgr.config.ConfigSingleton.java
License:Apache License
public static synchronized void setGsonRegistrations(GsonRegistrations registrations) { GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting(); registrations.register(builder);//from ww w. j av a 2 s . c om gson = builder.create(); }
From source file:com.google.gerrit.httpd.restapi.RestApiServlet.java
License:Apache License
private static void enablePrettyPrint(GsonBuilder gb, Multimap<String, String> config, @Nullable HttpServletRequest req) { String pp = Iterables.getFirst(config.get("pp"), null); if (pp == null) { pp = Iterables.getFirst(config.get("prettyPrint"), null); if (pp == null && req != null) { pp = acceptsJson(req) ? "0" : "1"; }/*from w w w . j a va 2 s .com*/ } if ("1".equals(pp) || "true".equals(pp)) { gb.setPrettyPrinting(); } }
From source file:com.google.gerrit.server.OutputFormat.java
License:Apache License
/** @return a new Gson instance configured according to the format. */ public GsonBuilder newGsonBuilder() { if (!isJson()) { throw new IllegalStateException(String.format("%s is not JSON", this)); }/*from www . j a v a 2 s. c o m*/ GsonBuilder gb = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapter(Timestamp.class, new SqlTimestampDeserializer()); if (this == OutputFormat.JSON) { gb.setPrettyPrinting(); } return gb; }
From source file:com.google.mr4c.serialize.json.JsonAlgorithmBeanSerializer.java
License:Open Source License
public void serializeAlgorithmSchemaBean(AlgorithmSchemaBean algoSchema, Writer writer) throws IOException { GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting(); Gson gson = builder.create();/* w w w. j av a 2 s .c o m*/ gson.toJson(algoSchema, writer); }
From source file:com.google.mr4c.serialize.json.JsonConfigSerializer.java
License:Open Source License
private Gson buildGson() { GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting(); builder.registerTypeAdapter(Document.class, new DocumentSerializer()); return builder.create(); }
From source file:com.google.mr4c.serialize.json.JsonDatasetBeanSerializer.java
License:Open Source License
public void serializeDatasetBean(DatasetBean dataset, Writer writer) throws IOException { GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting(); Gson gson = builder.create();/* w w w . ja va 2 s. c o m*/ gson.toJson(dataset, writer); }
From source file:com.google.mr4c.serialize.json.JsonDatasetBeanSerializer.java
License:Open Source License
public String serializeDataFileBean(DataFileBean file) { GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting(); Gson gson = builder.create();/*from www .j a va 2 s .c om*/ return gson.toJson(file); }
From source file:com.google.mr4c.serialize.json.JsonDatasetBeanSerializer.java
License:Open Source License
public String serializeDataKeyBean(DataKeyBean key) { GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting(); Gson gson = builder.create();//w ww . j av a2s.com return gson.toJson(key); }
From source file:com.google.mr4c.serialize.json.JsonKeyspaceBeanSerializer.java
License:Open Source License
public void serializeKeyspaceBean(KeyspaceBean keyspace, Writer writer) throws IOException { GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting(); Gson gson = builder.create();//from ww w.java 2s.c o m gson.toJson(keyspace, writer); }
From source file:com.google.mr4c.serialize.json.JsonPropertiesSerializer.java
License:Open Source License
public void serializeProperties(Properties props, Writer writer) throws IOException { GsonBuilder builder = new GsonBuilder(); builder.setPrettyPrinting(); Gson gson = builder.create();// ww w. j a va 2s . c om gson.toJson(props, writer); }