gjq

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

README

gjq - Another Implementation of jq by golang

Build Status GitHub license GitHub release

Declare gjq module

See go.mod file.

Command-Line Interface

Binaries

See latest release.

Usage
$ gjq -h
Usage:
  gjq [flags] <filter string>

Flags:
  -c, --clipboard     copy to clipboard in interactive mode
  -C, --color         colorize JSON
      --debug         for debug
  -f, --file string   JSON data (file path)
  -h, --help          help for gjq
  -i, --indent int    indent size for formatted JSON string (default 2)
  -I, --interactive   interactive mode
  -t, --tab           use tabs for indentation
  -u, --url string    JSON data (URL)
  -v, --version       output version of gjq
Syntax of Filter

See savaki/jq.

syntax meaning
. unchanged input
.foo value at key
.foo.bar value at nested key
.[0] value at specified element of array
.[0:1] array of specified elements of array, inclusive
.foo.[0] nested value
Filtering JSON data from Stdin
$ cat testdata/test.json
{
  "string": "a",
  "number": 1.23,
  "simple": ["a", "b", "c"],
  "mixed": [
    "a",
    1,
    {"hello":"world"}
  ],
  "object": {
    "first": "joe",
    "array": [1,2,3]
  }
}

$ type testdata/test.json | gjq .object.array
[
  1,
  2,
  3
]
Filtering JSON data from file
$ gjq -f testdata/test.json .object.array
[
  1,
  2,
  3
]
Filtering JSON data from WWW
$ gjq -u https://text.baldanders.info/index.json .entry.[0]
{
  "title": "猫を殺すに猫を以ってせよ",
  "section": "remark",
  "description": "分かるかな。分っかんねーだろうな(反語)",
  "author": "Spiegel",
  "license": "http://creativecommons.org/licenses/by-sa/4.0/",
  "url": "https://text.baldanders.info/remark/2019/03/no-cat-no-life/",
  "published": "2019-03-11T13:51:41+00:00",
  "update": "2019-03-11T13:53:40+00:00"
}

Interactive Mode

$ gjq -u https://text.baldanders.info/index.json -I
Press Ctrl+C to stop
Filter> .entry.[0]
{
  "title": "猫を殺すに猫を以ってせよ",
  "section": "remark",
  "description": "分かるかな。分っかんねーだろうな(反語)",
  "author": "Spiegel",
  "license": "http://creativecommons.org/licenses/by-sa/4.0/",
  "url": "https://text.baldanders.info/remark/2019/03/no-cat-no-life/",
  "published": "2019-03-11T13:51:41+00:00",
  "update": "2019-03-11T13:53:40+00:00"
}
Filter> 

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL