Reputation: 75
I want to reference this json key : Added Date/Time
{{ contact.["Added Date\\Time"] }}
Why isn't this working?
Upvotes: 2
Views: 8490
Reputation: 19106
Because the string literal does not match the required key. You need to ensure that the string literal in your source code matches the actual JSON key.
In most languages, this character sequence will do it: Added Date/Time
. (there is no escaping required).
Note, this string is NOT a JSON string - it's a string literal in your programming language. Thus, this string must obey the escaping rules of your current programming language, not the rules of JSON.
Upvotes: 1
Reputation: 523
If you want to include a literal double quote in a JSON string, you must escape it by preceding it with a backslash . So your JSON string would have to look like this:
{"key" : " \"Some text WITH quotes\" "}
See json.org for the official JSON syntax.
The forward slash / is not a special character and does not need to be escaped. The backslash \ needs to be escaped with itself: \\.
Upvotes: 4