All Projects → jsqry → jsqry-cli2

jsqry / jsqry-cli2

Licence: MIT license
Small CLI tool (similar to jq) to query JSON using sane DSL

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects
python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to jsqry-cli2

Jqplay
A playground for jq, written in Go
Stars: ✭ 444 (+2014.29%)
Mutual labels:  jq
Jqr
R interface to jq
Stars: ✭ 123 (+485.71%)
Mutual labels:  jq
Jackson Jq
jq for Jackson Java JSON Processor
Stars: ✭ 178 (+747.62%)
Mutual labels:  jq
Jqaas
jq as a service
Stars: ✭ 22 (+4.76%)
Mutual labels:  jq
Live Dl
Download live streams from YouTube
Stars: ✭ 82 (+290.48%)
Mutual labels:  jq
Pyjq
A Python binding for ./jq
Stars: ✭ 133 (+533.33%)
Mutual labels:  jq
Awesome Jq
A curated list of awesome jq tools and resources.
Stars: ✭ 391 (+1761.9%)
Mutual labels:  jq
quickjs es runtime
this is a wrapper library for the javascript runtime quickjs written in rust which works with modules, promises, async, await and much more
Stars: ✭ 43 (+104.76%)
Mutual labels:  quickjs
Yq
Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
Stars: ✭ 1,688 (+7938.1%)
Mutual labels:  jq
Tmux 1password
🔑 Access your 1Password login items within tmux!
Stars: ✭ 167 (+695.24%)
Mutual labels:  jq
Java Jq
Lightweight Java wrapper around JQ, a flexible JSON processor available for multiple platforms
Stars: ✭ 37 (+76.19%)
Mutual labels:  jq
Okurl
OkHttp Kotlin command line
Stars: ✭ 77 (+266.67%)
Mutual labels:  jq
Node Jq
Node.js wrapper for jq
Stars: ✭ 147 (+600%)
Mutual labels:  jq
Aws
A collection of bash shell scripts for automating various tasks with Amazon Web Services using the AWS CLI and jq.
Stars: ✭ 493 (+2247.62%)
Mutual labels:  jq
Emuto
manipulate JSON files
Stars: ✭ 180 (+757.14%)
Mutual labels:  jq
Ticker.sh
Real-time stock tickers from the command-line.
Stars: ✭ 392 (+1766.67%)
Mutual labels:  jq
Oq
A performant, and portable jq wrapper to facilitate the consumption and output of formats other than JSON; using jq filters to transform the data.
Stars: ✭ 132 (+528.57%)
Mutual labels:  jq
jq-tutorial
Interactive exercises for learning jq
Stars: ✭ 109 (+419.05%)
Mutual labels:  jq
Jq Web
jq in the browser with emscripten.
Stars: ✭ 188 (+795.24%)
Mutual labels:  jq
Json Splora
GUI for editing, visualizing, and manipulating JSON data
Stars: ✭ 1,818 (+8557.14%)
Mutual labels:  jq

jsqry-cli2

Build and test

jsqry is a small command line tool (similar to jq) to query JSON using sane DSL.

The purpose of this app is to expose the functionality of jsqry JS library in form of CLI.

Unlike jsqry-cli this one is based on QuickJS by Fabrice Bellard.

Examples

query

$ echo '[{"name":"John","age":30},
         {"name":"Alice","age":25},
         {"name":"Bob","age":50}]' | jsqry 'name'
[
  "John",
  "Alice",
  "Bob"
]

first element

$ echo '[{"name":"John","age":30},
         {"name":"Alice","age":25},
         {"name":"Bob","age":50}]' | jsqry -1 'name'
"John"

use query parametrization

$ echo '[{"name":"John","age":30},{"name":"Alice","age":25},{"name":"Bob","age":50}]' \
    | jsqry '[ _.age>=? && _.name.toLowerCase().startsWith(?) ]' --arg 30 --arg-str joh 
[
  {
    "name": "John",
    "age": 30
  }
]

use as simple JSON pretty-printer

$ echo '[{"name":"John","age":30},{"name":"Alice","age":25},{"name":"Bob","age":50}]' | jsqry
[
  {
    "name": "John",
    "age": 30
  },
  {
    "name": "Alice",
    "age": 25
  },
  {
    "name": "Bob",
    "age": 50
  }
]

The output is pretty-printed by default. And colored!

something trickier

Filter greater than 2, map adding 100, sort descending, take last 2 elements. By combining these features you can build arbitrary complex queries. Find more on supported DSL.

$ echo '[1,2,3,4,5]' | jsqry '[_>2] {_+100} s(-_) [-2:]'
[
  104,
  103
]

full JS power

Since jsqry bundles the full-fledged JS engine in under 1 MB executable, the full power of JS is in your hands!

$ echo '["HTTP://EXAMPLE.COM/123", 
         "https://www.Google.com/search?q=test", 
         "https://www.YouTube.com/watch?v=_OBlgSz8sSM"]' | jsqry '{ _.match(/:\/\/([^\/]+)\//)[1].toLowerCase() }'
[
  "example.com",
  "www.google.com",
  "www.youtube.com"
]

help message

$ jsqry
jsqry ver. 0.1.2
Usage: echo $JSON | jsqry 'query'
 -1,--first     return first result element
 -h,--help      print help and exit
 -v,--version   print version and exit
 -c,--compact   compact output (no pretty-print)
 -u,--unquote   unquote output string(s)
 -as ARG,
 --arg-str ARG  supply string query argument
 -a ARG,
 --arg ARG      supply query argument of any other type

Compare to jq

https://gist.github.com/xonixx/d6066e83ec0773df248141440b18e8e4

Install

Current version: 0.1.2.

Sorry, but only Linux x64 is supported at the moment. Hopefully this will improve.

To install or update the tool simply run the command below.

$ sudo bash -e -c "
wget https://github.com/jsqry/jsqry-cli2/releases/download/v0.1.2/jsqry-linux-amd64 -O/usr/local/bin/jsqry
chmod +x /usr/local/bin/jsqry
echo \"jsqry \$(jsqry -v) installed successfully\" 
"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].