A JSON Query Language CLI tool
The core philosophy of jql:
- Keep its features as simple as possible
- Avoid redunduncy
- Provide meaningful error messages
- Eat JSON as input, process, output JSON back
cargo install jql
If you find some of the following examples confusing, please have a look at The JavaScript Object Notation (JSON) Data Interchange Format.
"This is a valid JSON text with one value"
jql example.json '.'
"This is a valid JSON text with one value"
{
"some": {
"property": "yay!"
}
}
jql example.json '"some"."property"'
"yay!"
{
"primes": [7, 11, 13]
}
jql example.json '"primes".[0]'
7
Please note that the following is also valid:
jql example.json '"primes"[0]"'
7
{
"cats": [{ "first": "Pixie" }, { "second": "Kitkat" }, { "third": "Misty" }]
}
jql example.json '"cats".[1:2]'
[
{
"second": "Kitkat"
},
{
"third": "Misty"
}
]
Please note that you can reverse it:
jql example.json '"cats".[2:1]'
[
{
"third": "Misty"
},
{
"second": "Kitkat"
}
]
Bonus, you can do it again to get it back:
jql example.json '"cats".[2:1].[1:0]'
[
{
"second": "Kitkat"
},
{
"third": "Misty"
}
]
Please note that you can still access the children:
jql example.json '"cats".[2:1].[0]."third"'
"Misty"
{
"one": [1, 2, 3],
"two": 2,
"three": 3
}
jql example.json '"one".[2:0],"two","three"'
[
[
3,
2,
1
],
2,
3
]
{
"laptops": [
{
"laptop": {
"brand": "Apple",
"options": ["a", "b", "c"]
}
},
{
"laptop": {
"brand": "Asus",
"options": ["d", "e", "f"]
}
}
]
}
jql example.json '"laptops"|"laptop"'
[
{
"brand": "Apple",
"options": ["a", "b", "c"]
},
{
"brand": "Asus",
"options": ["d", "e", "f"]
}
]
You can also combine a filter with a child selection, a multi-selection and ranges at the same time:
jql example.json '"laptops"|"laptop"."brand"'
[
"Apple",
"Asus"
]
jql example.json '"laptops".[1:0]|"laptop"."brand","laptops"|"laptop"."brand"'
[
[
"Asus",
"Apple"
],
[
"Apple",
"Asus"
]
]
Please note that you can combine filters to achieve the same result:
jql example.json '"laptops".[1:0]|"laptop"|"brand","laptops"|"laptop"|"brand"'
[
"Apple",
"Asus"
]
{
"dna": [[[[["c", "a", "c"]]]], "g", "t", [[["a", ["t"]]]]]
}
jql example.json '.."dna"'
[
"c",
"a",
"c",
"g",
"t",
"a",
"t"
]
{
".valid": 1337,
"": "yeah!",
"\"": "yup, valid too!"
}
jql example.json '".valid"'
1337
jql example.json '""'
"yeah!"
jql example.json '"\""'
"yup, valid too!"
jql input.json 'foo.bar' > output.json
jql -h
jql --help
jql -V
jql --version
jql -i example.json 'some.selector'
jql --inline example.json 'some.selector'