//两个 \\
String json = "{\"name\":\"ab\\\\n86cde\"}";
User user = new Gson().fromJson(json, User.class);
//解码后变为一个 \
System.out.println(user.name);
json = new Gson().toJson(user);
//编码后变为两个 \\
System.out.println("json=="+json);
JsonParser parser = new JsonParser();
JsonElement element = parser.parse(json);
JsonObject jsonObject = element.getAsJsonObject();
//还是两个 \\
System.out.println(jsonObject.toString());
结果
ab\n86cde
json=={"name":"ab\\n86cde"}
{"name":"ab\\n86cde"}