List of usage examples for com.google.gson GsonBuilder disableHtmlEscaping
public GsonBuilder disableHtmlEscaping()
From source file:com.srotya.tau.wraith.conditions.ConditionSerializer.java
License:Apache License
public static Condition deserialize(String condition) { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(Condition.class, new ConditionSerializer()); gsonBuilder.disableHtmlEscaping(); Gson gson = gsonBuilder.create();/*from w ww. ja v a 2 s . c o m*/ return gson.fromJson(condition, Condition.class); }
From source file:com.srotya.tau.wraith.conditions.ConditionSerializer.java
License:Apache License
public static String serialize(Condition condition) { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(Condition.class, new ConditionSerializer()); gsonBuilder.disableHtmlEscaping(); Gson gson = gsonBuilder.create();//from w w w . j a v a 2s . c o m return gson.toJson(condition, Condition.class); }
From source file:com.srotya.tau.wraith.rules.RuleSerializer.java
License:Apache License
/** * Serialize {@link Rule}s to JSON string * /*from ww w. j ava 2 s . c o m*/ * @param rules * @return rules as JSON */ public static String serializeRulesToJSONString(List<Rule> rules, boolean pretty) { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(Condition.class, new ConditionSerializer()); gsonBuilder.registerTypeAdapter(Action.class, new ActionSerializer()); gsonBuilder.disableHtmlEscaping(); if (pretty) { gsonBuilder.setPrettyPrinting(); } Gson gson = gsonBuilder.create(); return gson.toJson(rules); }
From source file:com.srotya.tau.wraith.rules.RuleSerializer.java
License:Apache License
/** * Serialize {@link Rule} to JSON string * //from w w w. ja v a 2 s .c o m * @param rule * @return rule as JSON */ public static String serializeRuleToJSONString(Rule rule, boolean pretty) { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(Condition.class, new ConditionSerializer()); gsonBuilder.registerTypeAdapter(Action.class, new ActionSerializer()); gsonBuilder.disableHtmlEscaping(); if (pretty) { gsonBuilder.setPrettyPrinting(); } Gson gson = gsonBuilder.create(); return gson.toJson(rule); }
From source file:com.srotya.tau.wraith.rules.RuleSerializer.java
License:Apache License
/** * Deserialize {@link Rule}s from JSON// ww w . jav a 2 s .co m * * @param jsonRule * @return array of ruleObjects */ public static SimpleRule[] deserializeJSONStringToRules(String jsonRule) { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(Condition.class, new ConditionSerializer()); gsonBuilder.registerTypeAdapter(Action.class, new ActionSerializer()); gsonBuilder.disableHtmlEscaping(); Gson gson = gsonBuilder.create(); SimpleRule[] rules = gson.fromJson(jsonRule, SimpleRule[].class); if (rules != null) { for (SimpleRule rule : rules) { sortActionsById(rule); } } return rules; }
From source file:com.srotya.tau.wraith.rules.RuleSerializer.java
License:Apache License
/** * Deserialize {@link Rule} from JSON//from w w w. ja va 2s . co m * * @param jsonRule * @return ruleObject */ public static SimpleRule deserializeJSONStringToRule(String jsonRule) { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(Condition.class, new ConditionSerializer()); gsonBuilder.registerTypeAdapter(Action.class, new ActionSerializer()); gsonBuilder.disableHtmlEscaping(); Gson gson = gsonBuilder.create(); SimpleRule rule = gson.fromJson(jsonRule, SimpleRule.class); sortActionsById(rule); return rule; }
From source file:com.vmware.dcp.common.serialization.JsonMapper.java
License:Open Source License
public static GsonBuilder createDefaultGsonBuilder(boolean isCompact) { GsonBuilder bldr = new GsonBuilder(); registerCommonGsonTypeAdapters(bldr); if (isCompact) { bldr.disableHtmlEscaping(); } else {/*from w w w.j a v a2s . co m*/ bldr.setPrettyPrinting(); } return bldr; }
From source file:com.vmware.xenon.common.serialization.JsonMapper.java
License:Open Source License
public static GsonBuilder createDefaultGsonBuilder(boolean isCompact, boolean isSensitive) { GsonBuilder bldr = new GsonBuilder(); registerCommonGsonTypeAdapters(bldr); if (!isCompact) { bldr.setPrettyPrinting();/* w w w . j a v a 2s. c om*/ } bldr.disableHtmlEscaping(); if (isSensitive) { bldr.addSerializationExclusionStrategy(new SensitiveAnnotationExclusionStrategy()); } return bldr; }
From source file:edu.isi.wings.portal.classes.JsonHandler.java
License:Apache License
public static Gson createRunGson() { GsonBuilder gson = new GsonBuilder(); gson.registerTypeAdapter(Date.class, new DateSerializer()); gson.registerTypeAdapter(Binding.class, new BindingSerializer()); gson.registerTypeAdapter(ValueBinding.class, new BindingSerializer()); return gson.disableHtmlEscaping().create(); //return gson.disableHtmlEscaping().setPrettyPrinting().create(); }
From source file:edu.isi.wings.portal.classes.JsonHandler.java
License:Apache License
public static Gson createDataGson() { GsonBuilder gson = new GsonBuilder(); gson.setDateFormat("yyyy-MM-dd"); return gson.disableHtmlEscaping().create(); //return gson.disableHtmlEscaping().setPrettyPrinting().create(); }