Code example for GsonBuilder

Methods: createregisterTypeAdapterserializeNullssetFieldNamingPolicy

0
	 *            whether nulls should be serialized 
	 * 
	 * @return created gson, never null 
	 */ 
	public static final Gson createGson(final boolean serializeNulls) {
		final GsonBuilder builder = new GsonBuilder();
		builder.registerTypeAdapter(Date.class, new DateFormatter());
		builder.registerTypeAdapter(Event.class, new EventFormatter());
		builder.setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES);
		if (serializeNulls)
			builder.serializeNulls();
		return builder.create();
	} 
 
	/** 
	 * Get reusable pre-configured {@link Gson} instance 
	 * 
	 * @return Gson instance 
	 */ 
	public static final Gson getGson() {
Contextual code suggestions in your IDE  Get Codota for Java