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 most prominent 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 popular
json-spec is even more time-consuming and the last
validictory is fast, but does not follow the standards.
So I created a library that is still in pure Python, but very fast. It works by producing a straightforward 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 essential 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.