StringEscapeUtils.escapeJava(),对json字符串转义
引入依赖:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.9</version>
</dependency>
转义前str:[{"quantity":4,"price":115,"outerId":"kd001-white"}]
使用StringEscapeUtils.escapeJava(str)方法
转义后str:[{\"quantity\":4,\"price\":115,\"outerId\":\"kd001-white\"}]