48

GitHub - itchyny/gojq: Yet another Go implementation of jq

 4 years ago
source link: https://github.com/itchyny/gojq
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

gojq Travis Build Status

Yet another Go implementation of jq.

Usage

 $ echo '{"foo": 128}' | gojq '.foo'
128
 $ echo '{"a": {"b": 42}}' | gojq '.a.b'
42
 $ echo '{"id": "sample", "10": {"b": 42}}' | gojq '{(.id): .["10"].b}'
{
  "sample": 42
}
 $ echo '[{"id":1},{"id":2},{"id":3}]' | gojq '.[] | .id'
1
2
3

Nice error messages.

 $ echo '[1,2,3]' | gojq  '.foo & .bar'
gojq: invalid query: .foo & .bar
    .foo & .bar
         ^  unexpected token "&"
 $ echo '{"foo": { bar: [] } }' | gojq '.'
gojq: invalid json: invalid character 'b' looking for beginning of object key string
    {"foo": { bar: [] } }
              ^

Installation

Homebrew

brew install itchyny/tap/gojq

Build from source

go get -u github.com/itchyny/gojq/cmd/gojq

Bug Tracker

Report bug at Issues・itchyny/gojq - GitHub.

Author

itchyny (https://github.com/itchyny)

License

This software is released under the MIT License, see LICENSE.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK