Poorjson.sh
A tiny and POSIX Shell compatible (portable) JSON parser and query tool, written in pure POSIX Shell, within 60 lines of codes, only requires `sed`. Compatible with bash, dash, zsh, busybox and any other POSIX shell.
Install / Use
/learn @ryncsn/Poorjson.shREADME
poorjson.sh
A minimal POSIX compatible JSON parser and query tool written in pure 60 lines of POSIX Shell code.
The goal is to be POSIX compatible, lightweight, and fast. Only requires sed.
Usage:
# Just pipe JSON to it, and use parameters to query:
# (Note strings are quoted with "")
echo '{"key": ["ele1", "ele2", "ele3", "ele4"]}' | ./poorjson.sh '"key"' 2
# Prints:
"ele3"
# If output is array or object, it's printed a token per line
echo '{"top-key": {"key1": [ "value1", "value2"], "key2": "value2"} }' | ./poorjson.sh '"top-key"' '"key1"'
# Prints:
[
"value1"
,
"value2"
]
# Use \* to match anything, multilevel matching is supported:
echo '{"key0": {"key1": ["ele1-1", "ele1-2"], "key2": ["ele2-1", "ele2-2"]}}' | ./poorjson.sh '"key0"' \* 1
# Prints:
"ele1-1"
"ele2-1"
# poorjson.sh prints the whole JSON one token per line if no param is given:
echo '{"key0": [{"key1": "val1"}]}' | ./poorjson.sh
# Prints:
{
"key0"
:
[
{
"key1"
:
"val1"
}
]
}
# poorjson.sh prints basic error message for invalid JSON
# To simply check if a JSON string is valid:
echo '{"key": "val"}' | ./poorjson.sh - && echo "valid" || echo "invalid"
# Prints:
valid
echo '{"key":: "val"}' | ./poorjson.sh - && echo "valid" || echo "invalid"
# Prints:
Unexpected token: ":"
invalid
echo '' | ./poorjson.sh - && echo "valid" || echo "invalid"
# Prints:
Unexpected EOF after: ""
invalid
Known issues
- If the same key appears multiple times in an object, poorjson.sh will simply parse them repeatedly.
- Due to the function call depths limit in Shell, JSON with thousands of levels of embedment can't be processed by poorjson.sh. But except that, it should be good enough for most common usage.
Test and comparison
Test result with JSONTestSuite:

Related Skills
node-connect
337.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.2kCommit, push, and open a PR
