Skip to content

Instantly share code, notes, and snippets.

@czechboy0
Last active March 4, 2016 22:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czechboy0/7c5261eb7b7797dbe542 to your computer and use it in GitHub Desktop.
Save czechboy0/7c5261eb7b7797dbe542 to your computer and use it in GitHub Desktop.
We need to talk about JSON "parsers".

We need to talk about JSON "parsers"

For the sake of a vibrant Swift community, we need to call things what they are. And what they aren't.

I recently wrote a JSON parser to accomodate for the lack of NSJSONSerialization on Linux. When searching for an existing one, I was caught by all these libraries which called themselves JSON parsers, but were in fact just wrapping calls to an actual underlying parser (usually NSJSONSerialization). They only provided convenience functions for unwrap values from dictionaries and mapping data to objects.

Those libraries are JSON-to-object mapping libraries. Those are JSON convenience function libraries.

These are not parsers. Rule of thumb: if your library needs a parser inside, it's not itself a parser.

Here's a definition of the word parser: http://en.m.wikipedia.org/wiki/Parsing

Parsing is the process of analysing a string of symbols, either in natural language or in computer languages, conforming to the rules of a formal grammar.

If your library doesn't actually analyze the incoming bytes to generate a JSON structure out of it, it's not a parser. (Neither it's a JSON decoder/encoder. All those words are reserved for the transformation between a structure and data in JSON).

Here's my full rant: https://twitter.com/czechboy0/status/705685127947485184

The whole reason why I'm getting worked up is because I spent hours looking for an existing JSON parser that would work on Linux, but was spammed by all these libraries that aren't parsers. I don't think conning SEO is a great feature in a development community, so let's call things what they are.

Just as you can't call Sublime Text a Swift compiler just because it can reindent Swift code, you can't call a JSON-to-object mapping libraries a parser just because it makes working with already parsed JSON easy.

I hope that if you have one of those libraries, you'll consider changing its description to something more appropriate and truthful.

Think about the poor kids like me looking for a tool and you wasting their time by calling your project something it isn't.

Sincerely, mildly frustrated
@czechboy0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment