json字符串添加转义\

String str ="{"employees":[{"firstName":"Bill","lastName":"Gates"},{"firstName":"George","lastName":"Bush"},{"firstName":"Thomas","lastName":"Carter"}]}";
String s = str.replaceAll("\"", "\\\\\"");
System.out.println(s);

posted @ 2021-06-28 21:56  iTao0128  阅读(2230)  评论(0)    收藏  举报