Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blgm/jfq
JSONata on the command line
https://github.com/blgm/jfq
jq json jsonata
Last synced: 9 days ago
JSON representation
JSONata on the command line
- Host: GitHub
- URL: https://github.com/blgm/jfq
- Owner: blgm
- License: mit
- Created: 2018-01-26T17:55:58.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2023-12-18T14:14:39.000Z (11 months ago)
- Last Synced: 2023-12-18T16:47:56.134Z (11 months ago)
- Topics: jq, json, jsonata
- Language: JavaScript
- Homepage: http://jsonata.org/
- Size: 2.98 MB
- Stars: 41
- Watchers: 1
- Forks: 3
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![npm](https://img.shields.io/npm/v/jfq.svg)](https://www.npmjs.com/package/jfq)
[![test](https://github.com/blgm/jfq/workflows/test/badge.svg?branch=main)](https://github.com/blgm/jfq/actions?query=workflow%3Atest+branch%3Amain)# jfq
[JSONata](http://jsonata.org/) on the command line.This was inspired by the excellent [jq](https://stedolan.github.io/jq/) utility, and uses JSONata rather than the
`jq` language.## Installation
```
npm install --global jfq
```## Usage
```
jfq [options] [] []
```It is good practice to put the JSONata query in single quotes, so that the shell does
not attempt to interpret it.The output will formatted as JSON, unless it's an array of simple objects (e.g. string, number)
when the output is flattened to a series of lines, so that it can be piped to another program such as `xargs`.Options
- `-n, --ndjson` output as newline-delimited JSON (each object on a single line)
- `-j, --json` force output as JSON, when it would normally be flattened
- `-y, --yaml` output as YAML
- `-a, --accept-yaml` accept YAML input
- `-q, --query-file ` read JSONata query from a file## Examples
- To read the version of JSONata from the file `package.json`:
```
jfq 'dependencies.jsonata' package.json# ^1.5.0
```- To find out how many downloads of JSONata there have been each month in the past year:
```
curl -s \
https://api.npmjs.org/downloads/range/last-year/jsonata \
| jfq 'downloads{$substring(day, 0, 7): $sum(downloads)}'# {
# "2017-02": 36216,
# "2017-03": 46460,
# "2017-04": 40336,
# ...
# }
```