🎉 Happy News! The new website is out :-) Google

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 path
  • json_keys — list keys of an object
  • json_length — count array elements
  • json_has — check if a key exists
  • json_file — parse from a file path