List of usage examples for com.google.gson GsonBuilder disableHtmlEscaping
public GsonBuilder disableHtmlEscaping()
From source file:org.springframework.http.converter.json.GsonFactoryBean.java
License:Apache License
@Override public void afterPropertiesSet() { GsonBuilder builder = (this.base64EncodeByteArrays ? GsonBuilderUtils.gsonBuilderWithBase64EncodedByteArrays() : new GsonBuilder()); if (this.serializeNulls) { builder.serializeNulls();//from w w w . ja va 2 s . co m } if (this.prettyPrinting) { builder.setPrettyPrinting(); } if (this.disableHtmlEscaping) { builder.disableHtmlEscaping(); } if (this.dateFormatPattern != null) { builder.setDateFormat(this.dateFormatPattern); } this.gson = builder.create(); }
From source file:password.pwm.util.java.JsonUtil.java
License:Open Source License
private static Gson getGson(final Flag... flags) { if (flags == null || flags.length == 0) { return GENERIC_GSON; }/*w w w .j av a 2 s . c o m*/ final GsonBuilder gsonBuilder = registerTypeAdapters(new GsonBuilder()); if (!JavaHelper.enumArrayContainsValue(flags, Flag.HtmlEscape)) { gsonBuilder.disableHtmlEscaping(); } if (JavaHelper.enumArrayContainsValue(flags, Flag.PrettyPrint)) { gsonBuilder.setPrettyPrinting(); } return gsonBuilder.create(); }
From source file:password.pwm.util.JsonUtil.java
License:Open Source License
private static Gson getGson(final Set<Flag> flags) { if (flags == null || flags.isEmpty()) { return GENERIC_GSON; }// www.j a v a 2s . c o m final GsonBuilder gsonBuilder = registerTypeAdapters(new GsonBuilder()); if (!flags.contains(Flag.HtmlEscape)) { gsonBuilder.disableHtmlEscaping(); } if (flags.contains(Flag.PrettyPrint)) { gsonBuilder.setPrettyPrinting(); } return gsonBuilder.create(); }
From source file:se.kth.karamel.backend.ClusterDefinitionService.java
public static String serializeJson(JsonCluster jsonCluster) throws KaramelException { GsonBuilder builder = new GsonBuilder(); builder.disableHtmlEscaping(); Gson gson = builder.setPrettyPrinting().create(); String json = gson.toJson(jsonCluster); return json;/*from w w w . j ava2 s. co m*/ }
From source file:se.kth.karamel.backend.running.model.tasks.DagBuilder.java
private static RunRecipeTask makeRecipeTaskIfNotExist(String recipeName, MachineRuntime machine, ClusterStats clusterStats, JsonObject chefJson, TaskSubmitter submitter, String cookbookId, String cookbookName, Map<String, RunRecipeTask> allRecipeTasks, Dag dag) throws DagConstructionException { String recId = RunRecipeTask.makeUniqueId(machine.getId(), recipeName); RunRecipeTask runRecipeTask = allRecipeTasks.get(recId); if (!allRecipeTasks.containsKey(recId)) { ChefJsonGenerator.addRunListForRecipe(chefJson, recipeName); GsonBuilder builder = new GsonBuilder(); builder.disableHtmlEscaping(); Gson gson = builder.setPrettyPrinting().create(); String jsonString = gson.toJson(chefJson); runRecipeTask = new RunRecipeTask(machine, clusterStats, recipeName, jsonString, submitter, cookbookId, cookbookName);/*from w w w.j a v a 2s . co m*/ dag.addTask(runRecipeTask); } allRecipeTasks.put(recId, runRecipeTask); return runRecipeTask; }
From source file:se.kth.karamel.backend.running.model.tasks.RunRecipeTask.java
@Override public List<ShellCommand> getCommands() throws IOException { Set<JsonElement> paramsToMerge = DagParams.getGlobalParams(); if (paramsToMerge != null) { try {//from www .j a va 2 s. co m // Merge in Global return results into the json file. JsonElement obj = new JsonParser().parse(json); if (obj.isJsonObject()) { JsonObject jsonObj = obj.getAsJsonObject(); for (JsonElement param : paramsToMerge) { if (param.isJsonObject()) { JsonObject paramObj = param.getAsJsonObject(); merge(jsonObj, paramObj); } } GsonBuilder builder = new GsonBuilder(); builder.disableHtmlEscaping(); Gson gson = builder.setPrettyPrinting().create(); json = gson.toJson(jsonObj); } else { logger.warn(String.format("Invalid json object for chef-solo: \n %s'", json)); } } catch (JsonIOException | JsonSyntaxException ex) { logger.warn(String.format("Invalid return value as Json object: %s \n %s'", ex.toString(), json)); } } if (commands == null) { String jsonFileName = recipeCanonicalName.replaceAll(Settings.COOKBOOK_DELIMITER, "__"); commands = ShellCommandBuilder.makeSingleFileCommand(Settings.SCRIPT_PATH_RUN_RECIPE, "chef_json", json, "json_file_name", jsonFileName, "log_file_name", jsonFileName, "sudo_command", getSudoCommand(), "task_id", getId(), "succeedtasks_filepath", Settings.SUCCEED_TASKLIST_FILENAME, "pid_file", Settings.PID_FILE_NAME); } return commands; }
From source file:se.kth.karamel.common.cookbookmeta.KaramelizedCookbook.java
public String getInfoJson() { if (json == null) { CookbookInfoJson cookbookInfoJson = new CookbookInfoJson(urls.id, metadataRb); GsonBuilder builder = new GsonBuilder(); builder.disableHtmlEscaping(); Gson gson = builder.setPrettyPrinting().create(); json = gson.toJson(cookbookInfoJson); }/* ww w .j a v a2 s . co m*/ return json; }
From source file:se.kth.karamel.common.stats.ClusterStats.java
public synchronized String toJsonAndMarkNotUpdated() { GsonBuilder builder = new GsonBuilder(); builder.disableHtmlEscaping(); Gson gson = builder.setPrettyPrinting().create(); String json = gson.toJson(this); updated = false;//from w w w .ja v a 2s .c o m return json; }