我想在文档中显示 JSON 对象。如果我执行以下操作,它就会起作用:
\begin{lstlisting}
{
"id": "5",
"key": "discardedCard"
}
\end{lstlisting}
但是如果我将代码扩展为如下形式,则编译文档时只会出现错误:
\begin{lstlisting}
{
"id": "5",
"key": "discardedCard",
"value": {
"suit": "DIAMONDS",
"rank": "QUEEN"
}
}
\end{lstlisting}
错误日志:
! Incomplete \iffalse; all text was ignored after line 19.
<inserted text>
\fi
l.19 "
suit": "DIAMONDS",
A forbidden control sequence occurred in skipped text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.
! Incomplete \iffalse; all text was ignored after line 19.
我想提供 MWE,但如果我在 MWE 中运行代码,它就会起作用。因此,看起来我的学士论文中的其他部分破坏了文档。
有没有办法以安全的方式输出列表中的代码或者可能转义?
答案1
我猜你有一个语言简写(babel?)定义"
做某事,你可以在本地关闭简写,这可能会有所帮助