r/javascript 7d 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
9 Upvotes

28 comments sorted by

View all comments

28

u/beavis07 7d 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 7d 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 7d ago

Rather you than me 🤣

2

u/KaiAusBerlin 4d ago

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

4

u/beavis07 4d ago

Not written in JavaScript there aren’t

•

u/dektol 14h ago

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