如何将 %d 视为 JSON 中的字符串

How to treat %d as a string in JSON

我正在使用 Visual Code Studio 作为我的 IDE,并想编写一个简单的打印片段:

printf("%d", );

片段:

 "Print": {
    "prefix": "printf",
    "body": [
        "printf("%d",);",
        ""
    ],
    "description": "print"
}

它是一个 JSON 文件,但我想它会给我一个 %d 错误,并且不会将 %d 视为字符串。错误是:Expected commajson(514)

您需要使用反斜杠转义出现在字符串中的双引号,否则看起来您正在结束并重新启动字符串:

 "Print": {
    "prefix": "printf",
    "body": [
        "printf(\"%d\",);",
        ""
    ],
    "description": "print"
}