我试图显示双引号,但它显示了一个反斜杠:
"maingame": {
"day1": {
"text1": "Tag 1",
"text2": "Heute startet unsere Rundreise \\\"Example text\\\". Jeden Tag wird ein neues Reiseziel angesteuert bis wir.</strong> "
}
}
当在html中呈现时,它显示为“示例文本\”。正确的方法是什么?
对于那些想使用开发人员powershell。下面是要添加到settings.json中的行:
"terminal.integrated.automationShell.windows": "C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe",
"terminal.integrated.shellArgs.windows": [
"-noe",
"-c",
" &{Import-Module 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\Tools\\Microsoft.VisualStudio.DevShell.dll'; Enter-VsDevShell b7c50c8d} ",
],
何时何地用“\\\”代替。好吧,如果你和我一样,当我发现这个帖子后意识到我在做什么时,你会觉得自己和我一样愚蠢。
如果你正在制作一个.json文本文件/流,并从那里导入数据,那么在双引号:\"之前只有一个反斜杠的主流答案就是你正在寻找的答案。
However if you're like me and you're trying to get the w3schools.com "Tryit Editor" to have a double quotes in the output of the JSON.parse(text), then the one you're looking for is the triple backslash double quotes \\\". This is because you're building your text string within an HTML <script> block, and the first double backslash inserts a single backslash into the string variable then the following backslash double quote inserts the double quote into the string so that the resulting script string contains the \" from the standard answer and the JSON parser will parse this as just the double quotes.
<script>
var text="{";
text += '"quip":"\\\"If nobody is listening, then you\'re likely talking to the wrong audience.\\\""';
text += "}";
var obj=JSON.parse(text);
</script>
+1:由于它是一个JavaScript文本字符串,双反斜杠双引号\\"也可以;因为双引号不需要在单引号字符串中转义,例如'\"'和'"'会产生相同的JS字符串。