EN
JavaScript - which characters are valid/invalid as JSON key name?
1
answers
0
points
I would like to use special characters like: -, $ and space for key names of objects (or JSON strings).
Are there any characters that can make a key name invalid or any characters that need to be escaped?
1 answer
0
points
Any valid string is a valid key.
For example, you can even use the " as long as you escape it:
// ONLINE-RUNNER:browser;
var object = { "Example \"quote\" as a key": 123 }
console.log(object["Example \"quote\" as a key"]); // 123
References
0 comments
Add comment