
Member-only story
Lets build it, simple: Newtonsoft.Json
All of my stories are free. If you aren’t a member, you can read it here.
In this blog post, we’re going to take a deep dive into the inner workings of a VERY popular JSON serialization library: Newtonsoft.Json.
We’ll do this by building a simplified version, highlighting the key concepts and techniques used under the hood. (Yes, System.Text.Json is the new default, but that doesn’t take away from Newtonsofts success (5.3B total downloads). In reality the 2 libraries are VERY similar)
A Warning (and a Promise)
Disclaimer: We’re not trying to recreate the library in all it’s glory. Our goal is to simplify and distill the essential ideas behind JSON deserialization. Don’t worry if our implementation is incomplete or inefficient — we’re focusing on understanding, not building production-ready code.
First, we’ll start by exploring the basics of JSON syntax and then move on to tokenization, breaking down the JSON string into individual tokens or key-value pairs. From there, we can begin to build a simple deserializer that will help us understand how these libraries work their magic.
The Basics: Understanding JSON
JSON (JavaScript Object Notation) has become an industry-standard format for exchanging data…