List of usage examples for com.google.gson GsonBuilder excludeFieldsWithoutExposeAnnotation
public GsonBuilder excludeFieldsWithoutExposeAnnotation()
From source file:org.openqa.grid.internal.utils.configuration.StandaloneConfiguration.java
License:Apache License
public JsonElement toJson() { GsonBuilder builder = new GsonBuilder(); addJsonTypeAdapter(builder);/*from w w w .j ava 2 s . c om*/ return builder.excludeFieldsWithoutExposeAnnotation().create().toJsonTree(this); }
From source file:org.primefaces.extensions.util.json.GsonExposeAwareConverter.java
License:Apache License
private GsonExposeAwareConverter() { GsonBuilder gsonBilder = new GsonBuilder(); gsonBilder.registerTypeAdapter(Date.class, new DateTypeAdapter()); gsonBilder.serializeNulls();/*from w ww. j ava 2 s . co m*/ gsonBilder.excludeFieldsWithoutExposeAnnotation(); gson = gsonBilder.create(); }
From source file:org.uorm.serializer.DefaultJsonSerializer.java
License:Apache License
/** * @return the gson/*from w w w . ja va 2 s . co m*/ */ public Gson getGson() { if (gson == null) { GsonBuilder gbuilder = new GsonBuilder(); if (serializeNulls) { gbuilder.serializeNulls(); } gbuilder.setDateFormat(datePattern); if (prettyPrinting) { gbuilder.setPrettyPrinting(); } if (excludeFieldsWithoutExposeAnnotation) { gbuilder.excludeFieldsWithoutExposeAnnotation(); } if (enableComplexMapKey) { gbuilder.enableComplexMapKeySerialization(); } if (version != null) { gbuilder.setVersion(version); } gson = gbuilder.create(); } return gson; }