TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

ASK HN: Why json strings only accepts double quotation mark(")?

2 pointsby gagan2020about 13 years ago
Today, I am parsing a document, which I coincidentally wrote as {'status':'ok'}. I spent lot of time checking browser requests and setting proper header and content-type to application/json.<p>Then, I remembered that somewhere I read that it accepts only double quotation mark. so I changed that to {"status":"ok"} and it worked like charm. Later I confirmed that from json.org also.<p>So, my question why only one quotation mark (i.e. " ) was supported by json? what were historical reasons for that.

1 comment

kaoliniteabout 13 years ago
Traditionally single quotes are used to represent a single character and double quotes represent strings, so that's presumably where it came from. As for why, I'm unsure. One of the great things about JSON is that its syntax is very close to the syntax that many languages use for representing arrays and the like, so perhaps it was to stay in keeping with languages like C where strings cannot use single quotes. That's just a guess though and I personally don't think it's a good enough reason - I'm always caught out by single quotes in JSON.