Command-line JSON processor

jq

jq is a lightweight and flexible command-line JSON processor.

Coverage Status, Unix: Build Status, Windows: Windows build status

If you want to learn to use jq, read the documentation at https://stedolan.github.io/jq. This documentation is generated from the docs/ folder of this repository. You can also try it online at jqplay.org.

If you want to hack on jq, feel free, but be warned that its internals are not well-documented at the moment. Bring a hard hat and a shovel. Also, read the wiki: https://github.com/stedolan/jq/wiki, where you will find cookbooks, discussion of advanced topics, internals, release engineering, and more.

Source tarball and built executable releases can be found on the homepage and on the github release page, https://github.com/stedolan/jq/releases

If you're building directly from the latest git, you'll need flex, bison (3.0 or newer), libtool, make, automake, and autoconf installed. To get regexp support you'll also need to install Oniguruma or clone it as a git submodule as per the instructions below. (note that jq's tests require regexp support to pass). To build, run:

git submodule update --init # if building from git to get oniguruma
autoreconf -fi              # if building from git
./configure --with-oniguruma=builtin
make -j8
make check

To build without bison or flex, add --disable-maintainer-mode to the ./configure invocation:

./configure --with-oniguruma=builtin --disable-maintainer-mode

(Developers must not use --disable-maintainer-mode, not when making changes to the jq parser and/or lexer.)

To build a statically linked version of jq, run:

make LDFLAGS=-all-static

After make finishes, you'll be able to use ./jq. You can also install it using:

sudo make install

If you're not using the latest git version but instead building a released tarball (available on the website), then you won't need to run autoreconf (and shouldn't), and you won't need flex or bison.

To cross-compile for OS X and Windows, see docs/Rakefile's build task and scripts/crosscompile. You'll need a cross-compilation environment, such as Mingw for cross-compiling for Windows.

Cross-compilation requires a clean workspace, then:

# git clean ...
autoreconf -i
./configure
make distclean
scripts/crosscompile <name-of-build> <configure-options>

Use the --host= and --target= ./configure options to select a cross-compilation environment. See also "Cross compilation" on the wiki.

Send questions to https://stackoverflow.com/questions/tagged/jq or to the #jq channel (http://irc.lc/freenode/%23jq/) on Freenode (https://webchat.freenode.net/).

Comments
  • JQ will not access keys beginning with @ (eg. as xml attributes generated by xq start)

    JQ will not access keys beginning with @ (eg. as xml attributes generated by xq start)

    I'm fairly sure this worked in a previous version, but since I had to upgrade my machine and reinstall JQ from scratch I am finding that I can't read the values of fields that begin with the @ character (as generated by XQ for XML attributes).

    echo '{"@text":"foo", "@font":"bar", "@icon":"baz"}' | jq ."@text"
    jq: error: syntax error, unexpected $end, expecting QQSTRING_START (Unix shell quoting issues?) at <top-level>, line 1:
    [email protected] 
    jq: error: try .["field"] instead of .field for unusually named fields at <top-level>, line 1:
    [email protected]
    jq: 2 compile errors
    

    Following the advice:

    echo '{"@text":"foo", "@font":"bar", "@icon":"baz"}'| jq .["@text"]
    no matches found: .[@text]
    

    Ideally the result should be:

    "foo"
    

    What is the correct way to escape the @ so that JQ can access the desired values ?

  • NoScript XSS warning when following link to jq manual

    NoScript XSS warning when following link to jq manual

    Describe the bug

    Following #name links to jq manual website give NoScript XSS warnings in firefox.

    To Reproduce

    The map description is at: https://stedolan.github.io/jq/manual/v1.6/#map(x),map_values(x)

    NoScript reports:

    NoScript XSS Warning

    NoScript detected a potential Cross-Site Scripting attack from [...] to https://stedolan.github.io Suspicious data: (URL) https://stedolan.github.io/jq/manual/v1.6/#map(x),map_values(x)

    This happens even if I encode (),%28%29%2C

    Expected behavior

    No warning from NoScript

    Environment (please complete the following information):

    • Linux (xubuntu 20.04)
    • jq 1.6 (website)

    Additional context

  • Provide ppc64le builds

    Provide ppc64le builds

    Describe the bug Not a bug but a feature request. You already provide static builds for x86 and x64 as a release. Could you please also provide the ppc64le binary as part of the release?

  • jq does not compile when the path to jq contains spaces

    jq does not compile when the path to jq contains spaces

    Describe the bug jq does not compile when the path to jq contains spaces.

    To Reproduce

    mkdir "dir with space"
    cd "dir with space2
    git clone [email protected]:stedolan/jq.git
    cd jq
    git submodule update --init # if building from git to get oniguruma
    autoreconf -fi              # if building from git
    ./configure --with-oniguruma=builtin
    make -j8
    CC       src/main.o
    CCLD     libjq.la
    /usr/bin/sed: can't read space/jq/modules/oniguruma/src/.libs/libonig.la: No such file or directory
    libtool:   error: 'space/jq/modules/oniguruma/src/.libs/libonig.la' is not a valid libtool archive
    make[2]: *** [Makefile:978: libjq.la] Error 1
    make[2]: Leaving directory '/home/user/src/work/emqx/dir with space/jq'
    make[1]: *** [Makefile:1179: all-recursive] Error 1
    make[1]: Leaving directory '/home/user/src/work/emqx/dir with space/jq'
    make: *** [Makefile:810: all] Error 2
    

    Expected behavior jq should compile without errors even if there are spaces in the path.

    Environment (please complete the following information):

    • Arch Linux (2022-07-08)
    • jq master branch (commit cff5336ec71b6fee396a95bb0e4bea365e0cd1e8)

    Additional context Not being able to have spaces in the path can be especially problematic if jq is integrated in other software and their build process.

  • JQ exists in case where it cant find the json key instead of silently continuing

    JQ exists in case where it cant find the json key instead of silently continuing

    Hello everyone, I am posting this request after some research which I couldn't reproduce Basically I want to parse multiple json keys from file - now the problem is that if one or more keys does not exist, the whole job gets terminated by an error instead of continuing to process the other keys

    What could I do against it?

Related tags
Json-match - Command line util for matching values in a JSON input

json-match Match JSON input by specifying key and value > json-match -json '{\"p

Jan 12, 2022
An open-source GitLab command line tool bringing GitLab's cool features to your command line
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Aug 9, 2022
A command line tool that builds and (re)starts your web application everytime you save a Go or template fileA command line tool that builds and (re)starts your web application everytime you save a Go or template file

# Fresh Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. If the web framework yo

Nov 22, 2021
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purpose—to prompt for a value to be included in another command line. readval prints

Dec 22, 2021
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.

dasel Dasel (short for data-selector) allows you to query and modify data structures using selector strings. Comparable to jq / yq, but supports JSON,

Aug 9, 2022
🔄 A command-line utility to export Protocol Buffers (proto) files to YAML, and JSON

proto2yaml ?? A command-line utility to export Protocol Buffers (proto) files to YAML, and JSON. Currently supported exports are for: Packages Service

Jul 25, 2022
A simple command line for convert CSV in JSON
A simple command line for convert CSV in JSON

C2J A simple command line for convert CSV in JSON list of objects based on header. Install With Go 1.17 or higher: go install github.com/edermanoel94/

Jul 18, 2022
rj is a command line tool show the HTTP Response as JSON
rj is a command line tool show the HTTP Response as JSON

rj rj is a command line tool show the HTTP Response as JSON Installation

Mar 29, 2022
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies.

asciigraph Go package to make lightweight ASCII line graphs ╭┈╯. Installation go get github.com/guptarohit/asciigraph Usage Basic graph package main

Aug 5, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.

Table of contents Introduction Reference Contributing Introduction Overview git-xargs is a command-line tool (CLI) for making updates across multiple

Aug 7, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command

git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command. You give git-xargs:

Feb 5, 2022
Package command provide simple API to create modern command-line interface

Package command Package command provide simple API to create modern command-line interface, mainly for lightweight usage, inspired by cobra Usage pack

Jan 16, 2022
A command line tool for simplified docker volume command built with go

dockervol A command line tool for simplified docker volume command built with go. Features: Remove anonymous volume (beta) Remove volume by matching n

Dec 18, 2021
Watcher - A simple command line app to watch files in a directory for changes and run a command when files change!

Watcher - Develop your programs easily Watcher watches all the files present in the directory it is run from of the directory that is specified while

Mar 27, 2022
Use the command to convert arbitrary formats to Go Struct (including json, toml, yaml, etc.)

go2struct-tool Use the command to convert arbitrary formats to Go Struct (including json, toml, yaml, etc.) Installation Run the following command und

Dec 16, 2021
LINE account link: Sample code for LINE account link
LINE account link: Sample code for LINE account link

LINE account link: Sample code for LINE account link This is sample code to demostration LINE chatbot account link, refer to document https://develope

Dec 11, 2021
argv - Go library to split command line string as arguments array using the bash syntax.

Argv Argv is a library for Go to split command line string into arguments array. Documentation Documentation can be found at Godoc Example func TestAr

May 7, 2022
CLI - A package for building command line app with go
CLI - A package for building command line app with go

Command line interface Screenshot Key features Lightweight and easy to use. Defines flag by tag, e.g. flag name(short or/and long), description, defau

Jul 29, 2022
Simple and complete API for building command line applications in Go

Simple and complete API for building command line applications in Go Module cli provides a simple, fast and complete API for building command line app

Jul 26, 2022