jql 0.2.0

A JSON query language CLI tool
jql-0.2.0 is not a library.
Visit the last successful build: jql-5.2.0

JQL

A JSON Query Language CLI tool

Installation 🚀

cargo install jql

Usage 🐨

If you find some of the following examples confusing, please have a look at The JavaScript Object Notation (JSON) Data Interchange Format.

Accessing the root

"This is a valid JSON text with one value"
jql example.json '.'
"This is a valid JSON text with one value"

Accessing a child

{
  "some": {
    "property": "yay!"
  }
}
jql example.json '"some"."property"'
"yay!"

Please note that the following is also valid:

jql example.json 'some.property'
"yay!"

Accessing an index

{
  "primes": [7, 11, 13]
}
jql example.json 'primes.0'
7

Please note that the following is also valid:

jql example.json 'primes."0"'
7

Accessing a range

{
  "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"

Multi-selection

{
  "one": [1, 2, 3],
  "two": 2,
  "three": 3
}
jql example.json 'one.2:0,two,three'
[
  [
    3,
    2,
    1
  ],
  2,
  3
]

Filter

{
  "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 a filter is applied at the group level.

Special characters

{
  ".valid": 1337
}
jql example.json '".valid"'
1337

Help 📖

jql --help