StringEscapeUtils反转义处理

从前端Nodejs传过来的JSON字符串突然由于安全问题进行了转义为了Unicode字符,将 " 转义为 "
具体如下:

String json = "[{"userId":"3494","userName":"Andy","effect":"true","groupId":1,"groupCode":"SYS1"},{"userId":"3494","userName":"Andy","effect":"true","groupId":2,"groupCode":"SYS2"}]";


最后解决:使用StringEscapeUtils.unescapeHtml4()进行反转义。

最后转化为如下JSON串:

[{"userId":"3494","userName":"Andy","effect":"true","groupId":1,"groupCode":"SYS1"},{"userId":"3494","userName":"Andy","effect":"true","groupId":2,"groupCode":"SYS2"}]

你可能感兴趣的:(技术总结)