TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

2 点作者 gagan2020大约 13 年前
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

kaolinite大约 13 年前
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.