idea/java中发送json报文转义其中的符号

发布时间 2023-04-24 09:02:56作者: hello20008

参照:https://jingyan.baidu.com/article/f3ad7d0fa291c849c2345b1a.html

 

代码如下:

 

package com.atguigu;

public class test {
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {


System.out.println("{\n" +
" \"appNo\" : \"a${num}"+i+"\",\n" +
" \"applicantCredentialCode\" : \"\",\n" +
" \"applicantCredentialNo\" : \"\",\n" +
" \"applicantName\" : \"\"\n" +
"},");

}
}

}

其中需要注意:

 

 \"a${num}"+i+"\"   本来应该是 \"a${num}\"在中间加上"+i+"