目的

Java字符串标准输出打印包含双引号方法

方法

将要打印的双引号进行转义

代码

@SpringBootTest(classes = {SpringTestApplication.class})
class SpringTestApplicationTests {

    @Test
    void contextLoads() {
        String str = "{\"key\":\"value\"}";
        System.out.println(str);
    }

}

效果

{"key":"value"}