Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是JSON:
"Title": "+%\%]?|¥¥|£+"
我需要转义其中的哪些字符才能使其有效?
\角色开始一个转义序列。\%不是有效的转义序列。
\
\%
如果你想要\as 数据,你需要转义它:
"Title": "+%\\%]?|¥¥|£+"
显然,您还需要将其包含在 JSON 对象中:
{ "Title": "+%\\%]?|¥¥|£+" }
如果您担心文件被保存和读取时使用了错误的字符编码或类似的东西,那么转义其中的一些可能会更安全。正如昆汀指出的那样,你需要逃避\,逃避英镑符号和日元也没有什么坏处。所有其他都是不需要转义的 ASCII 字符。