32

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?

Spontifixus
  • 6,570
  • 9
  • 45
  • 63
A.G.
  • 2,089
  • 3
  • 30
  • 52

2 Answers2

45

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

Daniel
  • 1,236
  • 1
  • 9
  • 13
Karthik
  • 1,005
  • 8
  • 7
17

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.

Community
  • 1
  • 1
Maxim
  • 7,207
  • 1
  • 30
  • 29