Do curly braces inside json string objects need to be escaped?

前提是你 提交于 2019-12-18 18:54:05

问题


This string is part a JSON object/file:

"Mask" : "{0}(CASE WHEN {1} = {2} THEN {3} ELSE 0 END) {4}"

Will JSON recognize that as part of standard JSON notation or do I need to escape those curly braces s somehow?

If so, how does one escape curly braces in JSON?


回答1:


No. Curly braces do not have to be escaped in JSON.




回答2:


No, curly braces do not have to be escaped in JSON strings.

JSON is defined in RFC 7159. The Section 7: Strings lists the string characters that must be escaped:

All Unicode characters may be placed within the quotation marks, except for the characters that must be escaped: quotation mark, reverse solidus, and the control characters (U+0000 through U+001F).

While all characters can be escaped, curly braces do not have to be.



来源:https://stackoverflow.com/questions/19878079/do-curly-braces-inside-json-string-objects-need-to-be-escaped

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!