Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



19 Commits

Repository files navigation

Parsing JSON

Source Code to the Parsing JSON Blog Posts:

Follow along from the tags:

To setup, clone this repo:

git clone

JSON parsing that is common in Objective-C is actually a Data Mapping problem. The articles cover formulating the problem and building an abstraction to try and maximize the code reuse.

Note: If you just want a library to use, the writing is all based off of the Hydrant project. This isn't intended for production use


To verify my work (and prevent sleepless nights), the code here is tested. They use the Cedar testing framework. Using ⌘-U will run the tests. The fact that this project is a static library is merely a random choice.

The End Result

The end result of the series is a single Mapper protocol which individual mappers conform to. Each class solves a small part of the bigger problem, which allows composition and code reused with little assumption of other followers of the protocol.

This design, while more verbose, can cover more scenarios that is harder to do with a single-object API and allows developers the same flexibility of extending this code for more special cases. An example is optionally dropping bad JSON objects inside an array.

Those with a keen eye may notice that the overall structure is a more immutable and functional design. The object-oriented syntax does significantly balloon the code size which most functional programming languages minimize.