Check out a free preview of the full The Good Parts of JavaScript and the Web course

The "JSON" Lesson is part of the full, The Good Parts of JavaScript and the Web course featured in this preview video. Here's what you'd learn in this lesson:

Doug shares some thoughts about his work on the JSON data format. He also gives some advice to anyone designing alternative data formats.

Preview
Close

Transcript from the "JSON" Lesson

[00:00:00]
>> [MUSIC]

[00:00:03]
>> Douglas Crockford: Now it turns out I have a little bit of experience at convincing everybody in the world to do the right thing.
>> Audience: [LAUGH]
>> Douglas Crockford: For example, there's the JSON data interchange format, the world's best loved data interchange format. It took a while to convince everybody but eventually everybody got on board, and the death threat stopped and we're all happy about it now.

[00:00:26]
I'm very happy to report that this took much less than a generation. This is one of those very rare things where we're able to move it in just a few years. So, if you look at Google Trends and compare the trends of JSON versus XML, you'll see that the world has steadily been losing interest in XML.

[00:00:46]
Looks like that the years are chopped off here but it's on the other screen. Since 2005 the world has steadily been losing interest in XML. And we've slowly, quietly been seeing interest in JSON creeping up. And this increase was not motivated by any industry. There is no JSON industry which drives this there, because all the tools are free and simple and so it's just happening because you decided this is a better way of doing things and so it's just taking up.

[00:01:20]
So I can't predict when these lines cross over but Google can, so looks like next year for sure JSON becomes officially more interesting according to Google than XML.
>> Speaker 2: But in terms of use people who were using JSON, as a data interchange there's more people using JSON, right?

[00:01:41]
>> Douglas Crockford: I have no way of knowing. It seems like that to me too but-
>> Speaker 2: I think they're just Googling XML because it's still difficult and we don't have to Google a JSON so often cuz it's easy.
>> Douglas Crockford: I think there's a lot to it there, yeah, so a lot of.

[00:01:54]
If the search suggestions, XML sucks, that's a popular thing, you don't see that on JSON searches. So there may very well be something to that. So I did not intend for JSON to be the last data interchange format. JSON was intended to do a very specific thing of allowing applications written in different languages to be able to communicate with each other over the Internet.

[00:02:23]
But JSON is now being used for lots of other things, things that it wasn't necessarily designed for and so I expect they're going to be other data formats as well. So, I have some advice to anybody else who might be designing another data format. Number one, please don't break JSON.

[00:02:41]
JSON is working really well for the thing that it was originally designed for. One of the best things that I did in JSON was, I did not put a version number on it. So there is no way to revise it. We can't say JSON 1.1 because there was no JSON 1, it's just JSON.

[00:03:00]
So the way it is, is the way it will always be, which is great because if you look at the stack. I expect over the years the stack is gonna be changing all the time at every level, except in the JSON layer. The JSON layer will always work the way it does right now.

[00:03:19]
And that's a pretty nice thing, having that level of reliability, the integrity and anything in the net is huge. I can't think of any feature we could add to JSON which is more valuable than that. So, if you want to make something else, please make something else and make it better.

[00:03:37]
But don't try to break JSON, leave JSON alone.
>> Douglas Crockford: Whatever you're gonna do, if you're gonna do something that's kind of like JSON but different, make it significantly better. If it's just JSON with one or two little things, then what you're doing is you're adding a compatibility hazard to the world, that people are gonna have to deal with this thing which is kind of like JSON but isn't.

[00:04:00]
And so there's a cost to that. So make sure the cost is worth it, add enough value to it to justify that cost. And get a better name because no question, the worst thing about JSON is the name. For one thing people are confused about how to pronounce it.

[00:04:20]
I say JSON, a lot of people say JSON, it turns out the correct pronunciation is JSON.
>> Audience: [LAUGH]
>> Douglas Crockford: Everybody?
>> Audience: JSON.
>> Douglas Crockford: [LAUGH] Yeah, so and I hear from guys all the time named Jason saying, I'm in the office and I hear someone saying, what. So, I'm sorry Jason if you're here.

[00:04:44]
I don't know what I was thinking, sorry. So I've heard from guys named Jason that threaten to make new standards called Douglas, so just to show me what it's like. But again, the worst thing about JSON is the name. It stood for JavaScript Object Notation and almost everything about that is wrong.

[00:05:07]
So I called it JavaScript because I wanted to give credit to JavaScript because that is where the idea came from. I didn't invent JSON, I discovered it already in this language and I was trying to give respect to it. I was not trying to jump on JavaScript's coat-tail because I'll tell you in 2001, JavaScript was not a much loved language, right?

[00:05:28]
In saying, I'm JavaScript, that's not a way to get credibility from anybody. I was just trying to be honest, I was just trying to recognize where it came from. But the name is problematic, for one thing people still don't know what Java is versus JavaScript, and that stuff is still going on.

[00:05:49]
And also there is a confusion that, so JSON only works with JavaScript, no, that's not true, that was never true. There is also a confusion that I guess the JavaScript language standard is what defines JSON and that was never true. But there are all these confusions that happened because I chose the wrong name.

[00:06:09]
>> Speaker 2: What should you have called It?
>> Douglas Crockford: I don't know.
>> Audience: [INAUDIBLE]
>> Douglas Crockford: That boat has sailed, we're done. Then there is object, object here represents the way that JavaScript thinks about objects right, just a loose collection of key value pairs, that's an object. Which is not the way most languages think about objects, right?

[00:06:30]
They have this more brittle thing, we've got classes and instances, and so on. So they get confused that we can send them a JSON object and they go that's not an object, yeah. Notation, maybe that's okay. So notation is bad. So if you're going to make up a new data standard and I think you should, don't call it JSON.

[00:06:50]
Don't stick a letter in front of it or a letter on the end of it or anything like that. Come up with some creativity, do something good there.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now