java gson replace password value while serialization
问题 How can I replace the value of a password field with XXX while de-serializing an object with Gson? I found this post: Gson: How to exclude specific fields from Serialization without annotations that basically skips the field. This would be an option, but I still would prefer to replace the value with XXX I also tried this: GsonBuilder builder = new GsonBuilder().setPrettyPrinting(); builder.registerTypeAdapter(String.class, new JsonSerializer<String>(){ @Override public JsonElement serialize