Languages

JavaScript - which characters are valid/invalid as JSON key name?

0 points
Asked by:
Remy-Lebe
832

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
Answered by:
Admin Dirask Community
4380

Any valid string is a valid key.

For example, you can even use the " as long as you escape it:

 

References

  1. https://www.json.org/
0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join