json值里面带有英文引号无法解析的问题
示例
如图:万千宠爱,是由中文引号,不会造成解析失败
购好物,是英文引号,解析失败
解决方式,替换英文引号
public static String replaceString(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);
}