interactive jq, a REPL
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cmd/ijq-bare
.gitignore
README.md
main.go

README.md

ijq stands for "interactive jq", the super-powered jq REPL with support for:

  • automatic variable assignment -- so you won't lose your history!
  • global function definition -- define functions now, use them later in the same session!
  • import and include statements!

Example session

fiatjaf@cantillon ~> echo '{"numbers": [1,2]}' > data.json
fiatjaf@cantillon ~> echo 'def sum(a;b): a + b;' > math.jq
fiatjaf@cantillon ~> ijq data.json 
(./jq)| import "math" as math
(./jq)| math::sum(.numbers[0]; .numbers[1])
3 as $v1
(./jq)| $v0 | .sum = $v1
{
  "numbers": [
    1,
    2
  ],
  "sum": 3
} as $v2
(./jq)| def addtag(tagname): .tags = (.tags // []) | .tags += [tagname]
(./jq)| $v2 | addtag("silly-math")
{
  "numbers": [
    1,
    2
  ],
  "sum": 3,
  "tags": [
    "silly-math"
  ]
} as $v3
(./jq)| addtag("trivial")
{
  "numbers": [
    1,
    2
  ],
  "sum": 3,
  "tags": [
    "silly-math",
    "trivial"
  ]
} as $v4
(./jq)| ⏎

Installation

go get github.com/fiatjaf/ijq/...

Recommended:

sudo apt-get install rlwrap # or whatever, but please install rlwrap

Then

ijq [file]

FAQ

My commands are failing and I don't understand why!

Use the special debug command, you'll get the full filter that is being passed to jq and will be able to know what is happening. If it is a bug on ijq report it here please!


Mentioned in Awesome jq