That code work at least on Bash 3.2.57 and above.
This is a pure Bash implementation with no dependencies.
Maybe there are some unimplemented important things. If anyone need anything from it, please contact to me, and i will try to do it.
git clone https://github.com/lirik90/bashJsonParser.git
bash bashJsonParser/example.sh
source <(curl -s -L -o- https://github.com/lirik90/bashJsonParser/raw/master/jsonParser.sh)
JSON='{"error": "Error message text"}'
JSON=$(minifyJson "$JSON")
echo "Message is: $(parseJson "$JSON" error)"
- Copy code from jsonParser.sh file
- Get JSON from something place
read -d '' JSON << EOF
[{
"name": "Leanne Graham",
"company": {
"name": "Romaguera-Crona",
}
}]
EOF
- If your JSON is 'pretty' formatted wrap it with minify function like bellow:
JSON=$(minifyJson "$JSON")
- Choose field witch you want to parse
company=$(parseJson "$JSON" 0 company name)
echo "Company is: $company"