当json串传输异常(乱码破坏格式),服务器不能解析时,可以截取串达到取值的目的

String a =JSON.toJSONString(json);   //json(格式固定)转变为string串
                    String ret= null;
                    String regex="userName(.*?)fullName";   //设置截取范围
                    Matcher matcher=Pattern.compile(regex).matcher(a);
                    while(matcher.find())
                    {
                     ret=matcher.group(1);
                      
                    }
                    pname = ret.substring(6,ret.length()-6);   //去掉“,等符号

原文地址:https://www.cnblogs.com/anhao/p/6076482.html