
Show HN: Jwalk, a Streaming JSON Parser for Unix - sstephenson
https://jwalk.sh
======
x1n13y84issmd42
A JSON parser in Bash, impressive. I've just finished an HTTP server in Bash
and had to rely on _jq_ for parsing JSON requests, but maybe would love a pure
POSIX solution instead. Do you happen to have any benchmarks?

~~~
sstephenson
Performance depends on what toolset you’re using and how large your data set
is.

For small JSON documents, like a _package.json_ file, jwalk is around ten
times slower on my machine: 0.03 seconds, vs 0.004 seconds for jq.

For larger documents, like the 1.5 MB GitHub API response tree.json [1] in the
jwalk corpus, jwalk on mawk takes 0.37 seconds vs jq’s 0.11 seconds, but jwalk
uses just 1.18 MB of memory, vs jq’s 5.81 MB.

Other interpreted parsers don’t fare as well: JSON.awk [2], which only runs on
gawk, takes 0.8 seconds and 27 MB to parse tree.json; JSON.sh [3] takes 201
(!) seconds and 43 (!) MB, and JSONPath.sh [4] takes 7.4 seconds and uses 1.7
MB.

[1]
[https://raw.githubusercontent.com/shellbound/jwalk/master/te...](https://raw.githubusercontent.com/shellbound/jwalk/master/test/corpus/tree.json)

[2] [https://github.com/step-/JSON.awk](https://github.com/step-/JSON.awk)

[3]
[https://github.com/dominictarr/JSON.sh](https://github.com/dominictarr/JSON.sh)

[4]
[https://github.com/mclarkson/JSONPath.sh](https://github.com/mclarkson/JSONPath.sh)

