List of usage examples for com.google.gson GsonBuilder excludeFieldsWithModifiers
public GsonBuilder excludeFieldsWithModifiers(int... modifiers)
From source file:cc.kave.commons.utils.json.JsonUtils.java
License:Apache License
private static GsonBuilder createBuilder() { GsonBuilder gb = new GsonBuilder(); // add support for new Java 8 date/time framework gb.registerTypeHierarchyAdapter(LocalDateTime.class, new LocalDateTimeConverter()); Converters.registerAll(gb);/*from w w w . ja v a 2s. c om*/ gb.registerTypeAdapter(Duration.class, new DurationConverter()); GsonUtil.addTypeAdapters(gb); registerNames(gb); registerSSTHierarchy(gb); registerEventHierarchy(gb); gb.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE); gb.excludeFieldsWithModifiers(java.lang.reflect.Modifier.TRANSIENT); return gb; }
From source file:com.perl5.lang.perl.idea.run.debugger.PerlDebugThread.java
License:Apache License
protected Gson createGson() { GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(PerlDebuggingEvent.class, new PerlDebuggingEventsDeserializer(this)); return builder.excludeFieldsWithModifiers(Modifier.TRANSIENT).create(); }
From source file:edu.stanford.epad.epadws.processing.events.EventTracker.java
License:Open Source License
public synchronized String dumpProjectEvents(String sessionID) { StringBuilder result = new StringBuilder(); final GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.excludeFieldsWithModifiers(Modifier.PRIVATE); final Gson gson = gsonBuilder.create(); result.append("{ \"projectEvents\": "); if (projectEventMap.containsKey(sessionID)) { result.append(gson.toJson(projectEventMap.get(sessionID))); projectEventMap.get(sessionID).clear(); } else {/* w w w . j a v a2s . c om*/ result.append("[]"); } result.append(" }"); return result.toString(); }
From source file:net.signalr.client.serialization.gson.GsonSerializer.java
License:Open Source License
private static Gson build() { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.excludeFieldsWithModifiers(Modifier.STATIC); gsonBuilder.setFieldNamingStrategy(new ReflectiveFieldNamingStrategy()); return gsonBuilder.create(); }