private static Gson newGson() { return new GsonBuilder() .setPrettyPrinting() .registerTypeAdapter(EntityData.GlobalStore.class, new WorldHandler()) .registerTypeAdapter(EntityData.Entity.class, new EntityHandler()) .registerTypeAdapter(EntityData.Prefab.class, new PrefabHandler()) .registerTypeAdapter(EntityData.Component.class, new ComponentHandler()) .registerTypeAdapter(EntityData.Component.Builder.class, new ComponentBuilderHandler()) .registerTypeAdapter(EntityData.Value.class, new ValueHandler()) .serializeSpecialFloatingPointValues() .create(); }
private String getJSONString(CruiseControlParameters parameters) { Map<String, Object> optimizationResult = new HashMap<>(); if (((KafkaOptimizationParameters) parameters).isVerbose()) { optimizationResult.put(PROPOSALS, _optimizerResult.goalProposals().stream() .map(ExecutionProposal::getJsonStructure).collect(Collectors.toSet())); optimizationResult.put(LOAD_BEFORE_OPTIMIZATION, _optimizerResult.brokerStatsBeforeOptimization().getJsonStructure()); } optimizationResult.put(SUMMARY, _optimizerResult.getProposalSummaryForJson()); List<Map<String, Object>> goalSummary = new ArrayList<>(); for (Map.Entry<String, ClusterModelStats> entry : _optimizerResult.statsByGoalName().entrySet()) { String goalName = entry.getKey(); Map<String, Object> goalMap = new HashMap<>(); goalMap.put(GOAL, goalName); goalMap.put(STATUS, goalResultDescription(goalName)); goalMap.put(CLUSTER_MODEL_STATS, entry.getValue().getJsonStructure()); goalSummary.add(goalMap); } optimizationResult.put(GOAL_SUMMARY, goalSummary); optimizationResult.put(LOAD_AFTER_OPTIMIZATION, _optimizerResult.brokerStatsAfterOptimization().getJsonStructure()); optimizationResult.put(VERSION, JSON_VERSION); Gson gson = new GsonBuilder().serializeNulls().serializeSpecialFloatingPointValues().create(); return gson.toJson(optimizationResult); }
Gson gson = new GsonBuilder().serializeNulls().serializeSpecialFloatingPointValues().create(); responseMsg = gson.toJson(respMap); } else {
public GsonSerializer() { this(new GsonBuilder() .serializeSpecialFloatingPointValues() .create()); }
@Override public String toString() { return this.getClass().getSimpleName() + "{" + new GsonBuilder() .serializeSpecialFloatingPointValues() .create() .toJson(this) + '}'; }
@Override public String toString() { return this.getClass().getSimpleName() + "{" + new GsonBuilder() .serializeSpecialFloatingPointValues() .create() .toJson(this) + '}'; }
@Override public String toString() { return this.getClass().getSimpleName() + "{" + new GsonBuilder() .serializeSpecialFloatingPointValues() .create() .toJson(this) + '}'; }
public String toJson() { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() //.registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); return gson.toJson(this); }
private String getJsonToSave() { final Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() //.registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); return gson.toJson(user_edits.values()); }
public String toS() { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); return gson.toJson(this); }
public String toS() { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); return gson.toJson(this); }
public String toS() { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); return gson.toJson(this); }
public String toS() { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); return gson.toJson(this); }
public String toS() { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); return gson.toJson(this); }
public String toS() { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); return gson.toJson(this); } }
public String toS() { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); return gson.toJson(this); } }
public String toS() { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); return gson.toJson(this); }
public String toS() {//KS Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); Log.d("SENSOR", "Sensor toS uuid=" + this.uuid + " started_at=" + this.started_at + " active=" + this.isActive() + " battery=" + this.latest_battery_level + " location=" + this.sensor_location + " stopped_at=" + this.stopped_at); return gson.toJson(this); }
public String toS() {//KS Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); Log.d("SENSOR", "Sensor toS uuid=" + this.uuid + " started_at=" + this.started_at + " active=" + this.isActive() + " battery=" + this.latest_battery_level + " location=" + this.sensor_location + " stopped_at=" + this.stopped_at); return gson.toJson(this); }
@Test public void TestDeSerializationRightGson() { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.serializeSpecialFloatingPointValues(); Gson gson = gsonBuilder.create(); UserFloat userFloat = new UserFloat("Norman", Float.POSITIVE_INFINITY); String usersJson = gson.toJson(userFloat); System.out.println("userJson:" + usersJson); }