项目作者: fiatjaf

项目描述 :
interactive jq, a REPL
高级语言: Go
项目地址: git://github.com/fiatjaf/ijq.git
创建时间: 2018-02-17T04:00:38Z
项目社区:https://github.com/fiatjaf/ijq

开源协议:

下载


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

  1. fiatjaf@cantillon ~> echo '{"numbers": [1,2]}' > data.json
  2. fiatjaf@cantillon ~> echo 'def sum(a;b): a + b;' > math.jq
  3. fiatjaf@cantillon ~> ijq data.json
  4. (./jq)| import "math" as math
  5. (./jq)| math::sum(.numbers[0]; .numbers[1])
  6. 3 as $v1
  7. (./jq)| $v0 | .sum = $v1
  8. {
  9. "numbers": [
  10. 1,
  11. 2
  12. ],
  13. "sum": 3
  14. } as $v2
  15. (./jq)| def addtag(tagname): .tags = (.tags // []) | .tags += [tagname]
  16. (./jq)| $v2 | addtag("silly-math")
  17. {
  18. "numbers": [
  19. 1,
  20. 2
  21. ],
  22. "sum": 3,
  23. "tags": [
  24. "silly-math"
  25. ]
  26. } as $v3
  27. (./jq)| addtag("trivial")
  28. {
  29. "numbers": [
  30. 1,
  31. 2
  32. ],
  33. "sum": 3,
  34. "tags": [
  35. "silly-math",
  36. "trivial"
  37. ]
  38. } as $v4
  39. (./jq)|

Installation

Install using go install:

  1. go install github.com/fiatjaf/ijq/...@latest

Recommended:

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

Then

  1. 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