Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics (retiring) Programming AJAX Review JSON

Nelisa Loreto
Nelisa Loreto
5,436 Points

Do json property names really need to be in double quotes? Is this an old requirement?

I'm surprised that property names must be enclosed in double quotes. Assume this question needs updating?

Eg. https://teamtreehouse.com/nelisaloreto.json

2 Answers

andren
andren
28,558 Points

Yes. Properties in JSON have to be strings, and in JSON as string is defined as "a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes". In other words using single quotes, or no quotes at all is not allowed.

I'm not quite sure what is so surprising about it, JSON was made with simplicity in mind, and having strict rules about how it is formatted makes it far simpler to both programmatically create and read it in a consistent manner.

Nelisa Loreto
Nelisa Loreto
5,436 Points

Thanks, reviewed the video and understand.