jq is a lightweight and flexible JSON processor.
Project description
This project contains Python bindings for jq.
Installation
Wheels are built for various Python versions and architectures on Linux and Mac OS X. On these platforms, you should be able to install jq with a normal pip install:
pip install jq
If a wheel is not available, the source for jq 1.6 is downloaded over HTTPS and built. This requires:
Autoreconf
The normal C compiler toolchain, such as gcc and make.
libtool
Python headers.
Debian, Ubuntu or relatives
If on Debian, Ubuntu or relatives, running the following command should be sufficient:
apt-get install autoconf automake build-essential libtool python-dev
Red Hat, Fedora, CentOS or relatives
If on Red Hat, Fedora, CentOS, or relatives, running the following command should be sufficient:
yum groupinstall "Development Tools"
yum install autoconf automake libtool python python-devel
Mac OS X
If on Mac OS X, you probably want to install Xcode and Homebrew. Once Homebrew is installed, you can install the remaining dependencies with:
brew install autoconf automake libtool
Usage
Call jq.compile to compile a jq program. Call .input() on the compiled program to supply an input value. The input must either be:
a valid JSON value, such as the values returned from json.load
unparsed JSON text passed as the keyword argument text.
Calling first() on the result will run the program with the given input, and return the first output element.
import jq
assert jq.compile(".").input("hello").first() == "hello"
assert jq.compile(".").input(text='"hello"').first() == "hello"
assert jq.compile("[.[]+1]").input([1, 2, 3]).first() == [2, 3, 4]
assert jq.compile(".[]+1").input([1, 2, 3]).first() == 2
Call text() instead of first() to serialise the output into JSON text:
assert jq.compile(".").input("42").text() == '"42"'
When calling text(), if there are multiple output elements, each element is represented by a separate line:
assert jq.compile(".[]").input([1, 2, 3]).text() == "1\n2\n3"
Call all() to get all of the output elements in a list:
assert jq.compile(".[]+1").input([1, 2, 3]).all() == [2, 3, 4]
Call iter() to get all of the output elements as an iterator:
iterator = iter(jq.compile(".[]+1").input([1, 2, 3]))
assert next(iterator, None) == 2
assert next(iterator, None) == 3
assert next(iterator, None) == 4
assert next(iterator, None) == None
Calling compile() with the args argument allows predefined variables to be used within the program:
program = jq.compile("$a + $b + .", args={"a": 100, "b": 20})
assert program.input(3).first() == 123
Convenience functions are available to get the output for a program and input in one call:
assert jq.first(".[] + 1", [1, 2, 3]) == 2
assert jq.first(".[] + 1", text="[1, 2, 3]") == 2
assert jq.text(".[] + 1", [1, 2, 3]) == "2\n3\n4"
assert jq.all(".[] + 1", [1, 2, 3]) == [2, 3, 4]
assert list(jq.iter(".[] + 1", [1, 2, 3])) == [2, 3, 4]
The original program string is available on a compiled program as the program_string attribute:
program = jq.compile(".")
assert program.program_string == "."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for jq-1.2.1-pp37-pypy37_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 511028969e97191c824c65e5a26e8be0a7b7cf85f1b0241b3e1bc669a32dc483 |
|
MD5 | 4e6549f4f3b59b5d34ae1df370778f18 |
|
BLAKE2b-256 | d0303348ca9c95971eacbbb54f1610d96bf1054fc458eaae03ab0805901cc810 |
Hashes for jq-1.2.1-pp37-pypy37_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 720a1f5b03a605bc1db2dcfbdfdf45461eca6fe9a5e80d3721f7cd0960301bfe |
|
MD5 | 544a141b351a7dd98521d017a11bb346 |
|
BLAKE2b-256 | 70f73030ad06cc56d9afc75bc16aae6d4ac81536b31589b42a9c8b967bdc6b41 |
Hashes for jq-1.2.1-pp37-pypy37_pp73-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79381148408574a00c5497d687d530af126b079cd08aa930e0cdc6b735a25e55 |
|
MD5 | 517787d95becac1c93561e6813fee419 |
|
BLAKE2b-256 | 1389f6bf67ce185a43ecab4e4eaae89901a2d17ad85a7d03b74d0e10861559ac |
Hashes for jq-1.2.1-pp36-pypy36_pp73-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa2b4c8e90fdaef8dceb2df89091d85949d9661dabb5eaeafbf9b8fd60b2a858 |
|
MD5 | 609b99e429f981d87288e23eac0bac5a |
|
BLAKE2b-256 | c5eb9ea9aa0b64223b9e6851caddd9887577be4318e55cc76ff7bfdd2f7ffa22 |
Hashes for jq-1.2.1-pp36-pypy36_pp73-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 500d0540caaf89b8f24d88c51f7d0cc34d6772a4972bdad2dd3bea46c3f4a852 |
|
MD5 | ab810acbfe3757e802b34feeaa90ab29 |
|
BLAKE2b-256 | 3cbb6426bad34bdc24d2f22f191107f609e718310a74acc25752074003162f90 |
Hashes for jq-1.2.1-pp36-pypy36_pp73-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90dcea31ce4a5dd553bf29a505d6db178652374363ddfa3d7a8a9fa91784b85b |
|
MD5 | 6281523cb1d984ee30e1d8981547a23e |
|
BLAKE2b-256 | 1a79f5e7d2fce51777f3a01d0e6dbe35746c0e5e44d8794d7709fdc500f7be42 |
Hashes for jq-1.2.1-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f48b6dcaeb416a7ed81f61b1a8e45c722969e6b47f391db4af135f2b58033f00 |
|
MD5 | 9c1220d6407f17a14cb0c32d84a9d4f9 |
|
BLAKE2b-256 | 2941e90d34ca37b076a2a2c56345babbde49b36482693b01e593674ef274fc6f |
Hashes for jq-1.2.1-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b94c3937b3eb8afa420fe7990e6d99344e3b11ea7caf6d048ccf1aab74d5fe2 |
|
MD5 | 105c37ee3a3f7654bc8ec19739360c54 |
|
BLAKE2b-256 | e9a19e1d913f9f50faef48881da751051d38a02345095695c3297d72e43a9b66 |
Hashes for jq-1.2.1-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 960c6dd94af0ee62b8dfd0fece8d3fc2922b28610e2d8ce0bd2d4d850573162a |
|
MD5 | 963e63a4e1e8226ae9ea6245da8d58ca |
|
BLAKE2b-256 | 6147db5dd155fde2e55345ff89c921ab825d24269191fe9e8e1190a5adce7fc8 |
Hashes for jq-1.2.1-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 463c67cdf693a88329d58077c6edef6a58e94aecca34b6986a3a7841e1fa1f98 |
|
MD5 | 927a56c41c6374ef08562dd76f19073f |
|
BLAKE2b-256 | 76938e14c217f765f0854f7cb3e27ff601b48454a4afcb42b745d9391173e015 |
Hashes for jq-1.2.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 077ab6cf7d44483f052804d088229882940ba6b1c4f48bcf289ee62f7f957115 |
|
MD5 | 0504f798c8c13d6696cbbfbe0cc3c592 |
|
BLAKE2b-256 | abf430dd867c8bb803d388c58a13076271b260c940db6356a5622829bb3d72da |
Hashes for jq-1.2.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35314bb4e7ee37063057613231037dd15584b9173d3c7d70f20d192928f482c4 |
|
MD5 | 1cb70d30bfd5fd5d3e6f487c51c1111c |
|
BLAKE2b-256 | 774b057469a7ae6887209ebe693255c946ea5e446f91c2e69f0a0bef210e4ce5 |
Hashes for jq-1.2.1-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40b8267f36e7bda7a3c4547a4290a03734d1c5db73a17538342932963dab66d5 |
|
MD5 | 554cd71992656e50f15c8372740ebab7 |
|
BLAKE2b-256 | 0e7711fd79d362f51eaa9a4a5d043d31a838b12fbb89ab63ed721f314724926a |
Hashes for jq-1.2.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50cf1e9933331a4e880f1151000183336380e12c05654d1decce6db6f7af372c |
|
MD5 | 53097b90ec47cbc1a544a00f129e31b4 |
|
BLAKE2b-256 | 1930c78ed2f8ebeadc2fd2734d4c46b58c7e53da67af2d878401a98087e53071 |
Hashes for jq-1.2.1-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1971f1916f324b3b2a6b60cb373018df54144daded4284485c36a6d262744fb |
|
MD5 | 55a3bf7308062ffeb1b9f19567f96aed |
|
BLAKE2b-256 | f445ba1c8e49b430faf7d9231d817bfd73bad5bd2e610dfa456a790fbfd9c542 |
Hashes for jq-1.2.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15af0237c5a60edbaf000eb855a3f8dbf0efa7382a1d7f522ec5c8cbff3f58f5 |
|
MD5 | 058fd52d28bbfde151ee34553c676849 |
|
BLAKE2b-256 | e79a49d264f414a9abbc1b0eb510f35d1603fe51a0c183a11ae03861dc3bdb34 |
Hashes for jq-1.2.1-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48470748acf82194ba890705a4acd92db6ba898b9c78910d7fe051c7ea5a0715 |
|
MD5 | a0796cc80ec216d559c2222442dd8643 |
|
BLAKE2b-256 | 96baed09a41a5637a21b1d32a3d6c31b6bedb4c009ae7ef6d8f668c1b59769d6 |
Hashes for jq-1.2.1-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94d7c4b813188f70a2a5c19ddd6e385e3a2c4d20ed85c62fe0af58ebed6060b7 |
|
MD5 | b6e0151534c8b535a85ba8b17b71fe34 |
|
BLAKE2b-256 | a38dded0f86706cfeab293169af6d6470eb1aa4027d82a471eff72e0948af677 |
Hashes for jq-1.2.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00a4ecc32f6c322dd3595e7cd983bf2af95f728bd9edef62c7302e771c416d18 |
|
MD5 | fad4b91f09db7280a033fa9e7b7c0ebd |
|
BLAKE2b-256 | 64f918fd16f8c6e3989db5a7cd959e06646fcc2d8116bc199df30c54b348754f |
Hashes for jq-1.2.1-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c8a8d09c9d8e8ffcd82edc9ee5eb9f5083cf4fc2f6b8b576e722bcc68b41631 |
|
MD5 | a84a755766c8006944361d8b739609e8 |
|
BLAKE2b-256 | a83da1829a77b560792a661a86a70ccf794f4aa77ed320ed82bdcd977d80d6ff |
Hashes for jq-1.2.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3bc5fe6fe88bdea2e1c4b8a00316c550c11ce08d083793318d5b1af162422fe |
|
MD5 | a7d45ecced1512f840d069ec54a08f69 |
|
BLAKE2b-256 | bc9349c75b318e7f5ff063475bbac56cfed93fcd85bed743e5c710c59b9d0026 |
Hashes for jq-1.2.1-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afd136f9c2a239c6af90d0bb8aeed6d220dfb2ff11f9149d4103dca0829d0334 |
|
MD5 | 4bf335a687cc63df8fa216402402a9d5 |
|
BLAKE2b-256 | da466cb73d97a335dda7658566885fbf067132755c8cbcec174d3eee86787566 |
Hashes for jq-1.2.1-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fbcb7bfa4c756f3353d696469917817fc18f567090bc6d50bf346e7e6720747 |
|
MD5 | 222607ee34655f376ba3b33ba0bc4faa |
|
BLAKE2b-256 | d3418d7eb0d8fe218c58ddd20dc7c37520b64b9a120c97ebaf7535e982926089 |
Hashes for jq-1.2.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f06cdb4309445801d298168631ce3bc6a764352c8b5d6c89631826311272ba64 |
|
MD5 | 19d2b4bb146890fbe19fd071f37aa7e0 |
|
BLAKE2b-256 | f895c20dcf85a09f71e6cf8ee4601ff0152577db3839eb7f6f1932bcf5701810 |
Hashes for jq-1.2.1-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b551b78d786f01d554fd91c81de2d3ad0d140421cc07f2e5a947ecf8224abf78 |
|
MD5 | d483eb5611f070b35ef75a44780672c1 |
|
BLAKE2b-256 | 7657f00e14b9c5557c8eb3a1132876c515d08e79b947394d026a5db513600fca |
Hashes for jq-1.2.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a000519215a9fedcb2d37d542e5ebf3350c960179f6d1a4303324310e0b29622 |
|
MD5 | af833ac1bb3fa7f704647385f67976fa |
|
BLAKE2b-256 | 4721bcc0301f98c55a7911d2564654035afb1b2a5c65bc6cd051af94ef3a9518 |
Hashes for jq-1.2.1-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 524878c0e60565d5bdd82841e16bf8b2b30bdcc13d3972d691798afc45c4cbe1 |
|
MD5 | 3153846276bbe452ce995e0a4de9969b |
|
BLAKE2b-256 | d6ffce9b6f5d65f803ea38d1d7a95bdc63cdc7dcfd42e7b8c38cb20c9020abd1 |
Hashes for jq-1.2.1-cp35-cp35m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c285f2c14305081a11c8c02a2618ab138fcc1511aa91e665ce6d48e0b63d55e |
|
MD5 | 0b6c2d6f552fdc3e1121b874ddf86073 |
|
BLAKE2b-256 | d453744ebf27c186202fc97eb27dc24045d66f4ccf1fda5cdbca88efe0599e50 |
Hashes for jq-1.2.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d16531a062eae51de0e250c11aab61af6b3643014532c30c79b333fa965c685f |
|
MD5 | 1a36f2ae517875fc3731269157d46c3b |
|
BLAKE2b-256 | 3da724888a761b8484dbe63e199349c52cd7165062116413fdc53ce0d3e121b0 |
Hashes for jq-1.2.1-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 939e3a09f399cd57fb7ba4e9b3fd1574fd4f63b52b8de743a9319e67fded5811 |
|
MD5 | 3526deaebede6ee44ec45660c383577f |
|
BLAKE2b-256 | c0235066568187fc3e51c898ddeb98d31097294765d2840f40f6ec1e86187c3f |
Hashes for jq-1.2.1-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a18970e0cbcef44a311292fd1f6850d783bfd818b54def692cb61ea202af7c0 |
|
MD5 | ab95da2a33cabd1edbb7d147ce05efb8 |
|
BLAKE2b-256 | dd7cf35526785fe3a2b35b2c85695cf79248bf5fbd92e35ea01db659d0690b28 |