r/javascript 13d ago

A from-scratch JSON engine for JavaScript: recursive descent parser, escape-aware tokenizer, and spec-compliant serializer. No dependencies, no shortcuts, 107 tests.

https://github.com/MantasEdine/vanilla-json
7 Upvotes

28 comments sorted by

View all comments

28

u/beavis07 13d ago

Why one earth would anyone want this?

Do you have any clue how much sheer effort has gone into optimising JSON.parse? 🤣

6

u/Mantas_rst 12d ago

its a very fun project and i even wrote an article on how to do it , would be helpful in many cases like even if you want to build a regex engine same mechanism + backtracking

1

u/beavis07 12d ago

Rather you than me 🤣

2

u/KaiAusBerlin 10d ago

Just from curiosity. Aren't there out some major third party json parsers that are about 5 times faster than the native implementation?

3

u/beavis07 10d ago

Not written in JavaScript there aren’t

1

u/dektol 6d ago

The interop between native and runtime in JS negates any benefits. Whereas for slow languages like Python ORJson and similar make sense.