Others have well described *why* you’d want JSON (to transfer structured data between programs), but why is it the be all and end all of the modern web? The data representation problem has been solved a million times before with XML, HTML, SGML, HAML, YAML (yet another markup language), or in a more structured form with SOAP, CORBA, etc, etc. Why is JSON so pervasive? TL;DR . Web pages becoming the standard interface to everything. This wasn’t always the case…. JSON is simply what you’d get if you printed out a Javascript object. This is called “serialization” or “marshalling” in distributed programming. Let’s say I have an object I want to send from a server to a client. I can use lots of ways to send object data between two computers. CORBA, RMI, or SOAP used to be the main way to send data between two computers. T worked well to interoperate between C and Java and other application languages, but you had to be pretty fluent in order to use those well and the data formats were usually highly compact (often binary) so t didn’t read well. Along came XML, nice and readable and super extensible, but really, really wordy and ultimately not much easier to read to the average human. Then AJAX became really popular (the X stands for XML), but parsing XML is slow and debugging is hard. JSON had existed for a while as part of Javascript, and once JavaScript took off as the lingua franca of the web (killing off Flash, Java Applets, and others), JSON became the easiest way for a web page to use remote or saved data. You can directly convert JSON into a JavaScript object and vice versa. You lose most type information and functions (that CORBA and others supported), but most web pages are more concerned with display and not function. And that, kids, is why we have JSON everywhere.
With JavaScript and the DOM at the core, you have a way to create a web page in such an easy and intuitive manner that it is almost unnecessary. This is why I really dislike frameworks that use classes (instead of just creating objects with a constructor function) and/or require JavaScript skills to write. When I started this article, I asked myself: Why do sites still use class-based programming? To be honest, when I started this article, I asked myself the same thing. Why do frameworks use libraries? I know I ‛could’to have made it more concise, but I felt that these questions are important. In the end, all a web page really is an object in a tree. This object is stored and manipulated and maintained and rendered in a tree. And we must be careful to preserve this tree structure. If I were to write an actual application, this is.