JSON and Algebraic Data Types

Eric Normand's Newsletter
Software design, functional programming, and software engineering practices
Over 5,000 subscribers

I recently wrote about the birth of JSON, which describes how JSON came to be and the story of its success. Crawford talks about how JSON (or a very close equivalent) was reinvented several times throughout the years.

What strikes me is that JSON turned out to be an Algrebraic Data Type (ADT). Specifically, it is a tagged union.

JSON ADT variants:

  1. Null
  2. Boolean
  3. Number
  4. String
  5. List
  6. Dictionary

With these six constructors, you can make all of JSON.

It's interesting because JSON is a point of intersection between Javascript and Haskell. Javascript is very dynamic, with a very weak sense of type. Haskell has strong typing. On close analysis, JSON is statically and strongly typed. In fact, JSON is a type.

Could its ADT nature be one of the secrets to JSON's success?

Sean Allen
Sean Allen
Your friendly reminder that if you aren't reading Eric's newsletter, you are missing out…
👍 ❤️
Nicolas Hery
Nicolas Hery
Lots of great content in the latest newsletter! Really glad I subscribed. Thanks, Eric, for your work.
👍 ❤️
Mathieu Gagnon
Mathieu Gagnon
Eric's newsletter is so simply great. Love it!
👍 ❤️