bpkg-json
bpkg-json
Parse JSON from bash without requiring jq. Pure bash JSON query and extraction — lightweight and portable.
Installation
bpkg install dominictarr/bpkg-json
Usage
source bpkg_modules/bpkg-json/json.sh
data='{"name":"alice","age":30,"tags":["admin","user"]}'
json_get "$data" .name # → alice
json_get "$data" .age # → 30
json_get "$data" .tags[0] # → admin
json_keys "$data" # → name age tags
# Read from file
json_file /etc/config.json .database.host
Functions
json_get— extract a value by pathjson_keys— list keys of an objectjson_length— count array elementsjson_has— check if a key existsjson_file— parse from a file path