当前位置:网站首页>Handle double quotation mark escape in JSON string
Handle double quotation mark escape in JSON string
2022-06-11 05:23:00 【Bug repair robot】
1. The string passed from the foreground , adopt JSON.parseArray Turn into a collection
import com.alibaba.fastjson.JSON;
List<Subject> subjectList = JSON.parseArray(project.getSubjectStr(), Subject.class);2. The double quotation marks contained in the data will cause the conversion to fail
3. Method of escape
public static String formatErrorJson(String s) {
char[] temp = s.toCharArray();
int n = temp.length;
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);
}4. Then switch
5. Can be saved , Escape from the front end Or it can be parsed and converted into double quotation marks
String way=way.replace('”','"');边栏推荐
- Share | guide language image pre training to achieve unified visual language understanding and generation
- C (I) C basic grammar all in one
- Swap numbers (no temporary variables)
- 6 questions to ask when selecting a digital asset custodian
- What is the difference between gigabit network card and 10 Gigabit network card?
- Titanic rescued - re exploration of data mining (ideas + source code + results)
- Wechat applet uploads the data obtained from database 1 to database 2
- Section IV: composition and materials of asphalt mixture (2) -- main materials of asphalt
- Emnlp2021 𞓜 a small number of data relation extraction papers of deepblueai team were hired
- Project - Smart City
猜你喜欢

Restoration of binary tree -- number restoration

GAMES101作业7-Path Tracing实现过程&代码详细解读

Conversion relationship between coordinate systems (ECEF, LLA, ENU)

jvm调优六:GC日志分析和常量池详解

Cross modal retrieval | visual representation learning

BP neural network derivation + Example

Huawei equipment is configured with bgp/mpls IP virtual private network address space overlap

KD-Tree and LSH

Overview of self attention acceleration methods: Issa, CCNET, cgnl, linformer

Huawei equipment configures local virtual private network mutual access
随机推荐
在未来,机器人或 AI 还有多久才能具备人类的创造力?
Section II: structural composition characteristics of asphalt pavement (2) structural layer and performance requirements
49. grouping of acronyms
Titanic rescued - re exploration of data mining (ideas + source code + results)
Solving graph problems with union search set
Feynman learning method
About custom comparison methods of classes and custom methods of sort functions
Customize the layout of view Foundation
Share | defend against physically realizable image classification attacks
Deep extension technology: intelligent OCR recognition technology based on deep learning has great potential
mysql字符串转数组,合并结果集,转成数组
Share 𞓜 jointly pre training transformers on unpaired images and text
22. Generate parentheses
wxParse解析iframe播放视频
Target detection - personal understanding of RCNN series
Dongmingzhu said that "Gree mobile phones are no worse than apple". Where is the confidence?
Use acme SH automatically apply for a free SSL certificate
Sealem Finance打造Web3去中心化金融平台基础设施
Restoration of binary tree -- number restoration
White Gaussian noise (WGN)