JSON is used in many places. It’s easy to learn, read and use. JSON is also compact and won the battle with an XML to be a generic format to exchange data. But JSON has its problems as well. The biggest issue, I would say, is the same as the biggest feature—it’s very free.
We have to be able to validate data and for the JSON, there is JSON schema. “A vocabulary that allows you to annotate and validate JSON documents.”
Many languages implemented that in many libraries. Unfortunately, when you need to process a lot of data, but not A LOT to switch to a compiled language, it can be very slow.
For example, in Python, there are three main libraries.
The most popular
jsonschema is slow, the second most
json-spec is even slower and the last
is fast, but does not follow the standards.
So I created a library which is still in pure Python, but very fast. It works by producing a very simple and stupid Python code. Not complicated objects or other constructs.
jsonschematakes 5 seconds
json-spectakes 7 seconds
validitorytakes 380 miliseconds (but with bugs)
- and mine
fastjsonschematakes only 250 miliseconds
fastjsonschema has been here since 2016, but it supported
only the most important features of JSON schema. Now, there
is second version supporting all JSON features (including
draft 06 and 07) and is still incredibly fast. :-)
I’m giving big thanks to all contributors who helped to implement missing features and find the bugs.