java去掉json字符串中双引号

时间:2025-04-05 07:35:36

1.去掉字符串中的空格

2.去掉字符双引号

字符串{"fBNR":"<p style="text-align: center;"><span style="color: rgb(85, 85, 85); font-family: 仿宋; text-align: center; background-color: rgb(255, 255, 255);">——市水务系统志愿者助力包挂社区疫情防控工作</span></p><p><span style="color: rgb(85, 85, 85); font-family: 仿宋; text-align: center; background-color: rgb(255, 255, 255);"><span style="color: rgb(85, 85, 85); font-family: &quot;Microsoft Yahei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background-color: rgb(255, 255, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在防控新型冠状病毒感染肺炎疫情工作中,全市水务系统把发挥党员的先锋模范作用作为践行初心、担当使命的重要抓手,第一时间落实我市关于抽调*到社区参与新型冠状病毒感染的肺炎疫情防控工作的相关要求,积极动员全系统党员*自愿参与社区一线防疫工作。</span></span></p><p><span style="color: rgb(85, 85, 85); font-family: 仿宋; text-align: center; background-color: rgb(255, 255, 255);"><span style="color: rgb(85, 85, 85); font-family: &quot;Microsoft Yahei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background-color: rgb(255, 255, 255);">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: rgb(85, 85, 85); font-family: &quot;Microsoft Yahei&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; background-color: rgb(255, 255, 255);">在详细了解疫情防控工作情况后,1月27日起,水务系统志愿者即与相关区县党员*和村社区工作者共同开展出入人员登记、体温检测、防疫知识宣传、外来人员信息摸排统计、值守居家隔离人员等工作。&nbsp;一是突出重点再排查。在前期摸排的基础上,配合社区进行入户排查,共走访排查10余个小区,3000余户住户"}

//去空格
public String replaceBlank(String str) {
    String dest = "";
    if (str != null) {
        Pattern p = ("\\s*|\t|\r|\n");
        Matcher m = (str);
        dest = ("");
        // Pattern p2 = ("\\s*\"");
        // Matcher m2 = (dest);
        // dest = ("\'");
        dest = ("=\"", "='");
        p = ("\"\0*>");
        m = (dest);
        dest = (">'");
    }
    return dest;
}
//去双引号
public String jsonStringConvert(String s) {
    char[] temp = ();
    int n = ;
    for (int i = 0; i < n; i++) {
        if (temp[i] == ':' && temp[i + 1] == '"') {
            for (int j = i + 2; 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);
}