Flavius Popan

Decoding Elixir's JSON Journey

image_fx_

I listen to the Thinking Elixir Podcast every Tuesday, and recently heard the hosts mention libraries like Jason and Poison for JSON parsing. Digging deeper, I was surprised to realize that official JSON support was only added to the core language weeks ago, so I took it upon myself to understand the historical context. Here's what I learned:

The Early Days

Elixir 1.0 shipped without built-in JSON support, leaving the task to the community. In a recent interview, José Valim mentions intentionally keeping the core language small and focused, while encouraging the ecosystem to innovate for its needs as a way to stay competitive with companies like Google & Mozilla putting enormous resources into promoting their own languages like Go & Rust. Brilliant, and clearly worked!

Poison & Jason

Two libraries gained widespread adoption, first Poison in 2014, followed by Jason in 2017. Both cite Jiffy as an inspiration, which is written in C and implemented as a NIF (AKA a way to call other languages from Elixir). Jason took the lead by prioritizing speed and strict adherence to JSON standards. From its inaugural announcement post:

"You might be wondering, why do we need a new library? The primary focus of Jason is speed. And it it fast, really fast, usually twice as fast as Poison on both decoding and encoding and much closer to the performance of jiffy (which is implemented in C) - in some situations even faster." - michalmuskala

If you inspect an Elixir project on Github today, chances are you'll see Jason as a dependency as it's still widely used at the time of writing.

Official Support

In June of 2024, Erlang/OTP 27 added a native JSON module, followed by Elixir in December of 2024 with the 1.18 release. This was the first version I used when beginning my Elixir journey, which explains all the buzz I'm experiencing in my first few months in the ecosystem!

I plan on using the official module when I get to the point of actually needing a JSON library, but at least now I know how we got here :)

#elixir