DEV Community

Anil Kumar Maurya
Anil Kumar Maurya

Posted on • Originally published at Medium on

FastJsonparser, Fastest JSON parser for Ruby

FastJsonparser is ruby wrapper for simdjson which is written in c++.

JSON is de facto standard for exchanging data between web server and browser.

If your application is parsing large JSON data then you must consider optimising it for better performance.

I came across Simdjson which claims to parse gigabytes of JSON per second, It also claims to be over 2.5x faster than other production-grade JSON parsers. I thought this is fantastic why I am not using it.

I looked for the ways to use it and came across simdjson_ruby gem . It is wrapper for simdjson c++ library but unfortunately it was not working.

I started fixing it but got stuck in configurations then I thought why not create a new gem and import all code which I need from this gem, thus FastJsonparser was born.

To verify simdjson claim that it is really fast, I did benchmarking with existing gem Oj which claims to be fastest JSON parser for Ruby

Benchmark results:

  1. Parsing 1.2 MB JSON file

Check benchmark reference here

  1. Parsing local JSON

Check benchmark reference here

Clearly FastJsonparser outperforms both Oj and ruby’s built in JSON parser

How to Use FastJsonparser

Github: https://github.com/anilmaurya/fast_jsonparser

Let’s use it in your Ruby / Ruby on Rails projects and let me know how it performs.

P.S — Thank you https://github.com/saka1 for initial code.

Top comments (0)