Skip to content

Instantly share code, notes, and snippets.

View ryandabler's full-sized avatar

Ryan Dabler ryandabler

View GitHub Profile
@ryandabler
ryandabler / json-parser.js
Last active January 23, 2024 17:57
Complete example of a JSON parser for this article: https://itnext.io/demystifying-json-parse-383bb4907d79
const tokens = [
[/^\s+/, null],
[/^\[/, '['],
[/^]/, ']'],
[/^\{/, '{'],
[/^}/, '}'],
[/^:/, ':'],
[/^,/, ','],
[/^"/, '"'],
[/^\d+/, 'number'],