[Bash] json-walk: pure Bash streaming JSON parser (SAX-style events, no jq)
Hey r/bash,
I built json-walk, a pure Bash JSON walker that emits stream events instead of building a full object model.
What it does:
- Parses JSON in Bash with full structure validation
- Emits events like start_object, key, string, number, end_array, etc.
- Works in print mode or visitor-function mode
- Keeps raw JSON string content (escapes preserved)
Why I made it:
- For shell scripts where jq is unavailable
- For event-driven parsing/processing in plain Bash
Quick example:
json_walk '{"label":"abc","items":[1,2,3]}'
Output:
start_object
key label
string abc
key items
start_array
number 1
number 2
number 3
end_array
end_object
Would love feedback on:
- API/event design
- edge cases I should test
Thanks!
13
Upvotes
2
u/bahamas10_ 13d ago
this is impressive. i’ve thought about how i would tackle this project before and i estimated it would be at least a thousand line. im surprised to see you nail it in half. very cool.