zoukankan      html  css  js  c++  java
  • 去掉返回的json中特殊字符

    private static String jsonString(String s) {
        char[] temp = s.toCharArray();
        int n = temp.length;
        for (int i = 0; i < n; i++) {
            if (temp[i] == ':') {
                int quentIndex = i + 1;
                while (StringUtils.isBlank(String.valueOf(temp[quentIndex]))) {
                    quentIndex++;
                }
                if (temp[quentIndex] == '"') {
                    for (int j = quentIndex + 1; j < n; j++) {
                        if (temp[j] == '"') {
                            if (temp[j + 1] != ',' && temp[j + 1] != '}') {
                                temp[j] = '”';
                            } else if (temp[j + 1] == ',' || temp[j + 1] == '}') {
                                break;
                            }
                        }
                    }
                }
            }
        }
        return new String(temp);
    }
    

      

    private static String jsonString(String s) {    char[] temp = s.toCharArray();    int n = temp.length;    for (int i = 0; i < n; i++) {        if (temp[i] == ':') {            int quentIndex = i + 1;            while (StringUtils.isBlank(String.valueOf(temp[quentIndex]))) {                quentIndex++;            }            if (temp[quentIndex] == '"') {                for (int j = quentIndex + 1; j < n; j++) {                    if (temp[j] == '"') {                        if (temp[j + 1] != ',' && temp[j + 1] != '}') {                            temp[j] = '”';                        } else if (temp[j + 1] == ',' || temp[j + 1] == '}') {                            break;                        }                    }                }            }        }    }    return new String(temp);————————————————版权声明:本文为CSDN博主「JensonXIE」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/yefeng0810/article/details/98203137

  • 相关阅读:
    uva 11248 最大流 ISAP
    【力扣】133. 克隆图
    【力扣】125. 验证回文串
    【力扣】130. 被围绕的区域
    【力扣】337. 打家劫舍 III
    【力扣】104. 二叉树的最大深度-及二叉树的遍历方式
    【力扣】392. 判断子序列
    【力扣】95. 不同的二叉搜索树 II
    【力扣】120. 三角形最小路径和
    【力扣】两个数组的交集 II
  • 原文地址:https://www.cnblogs.com/panchangde/p/11898078.html
Copyright © 2011-2022 走看看