https://github.com/jorgehermo9/gq
A fast and feature rich JSON filtering tool
https://github.com/jorgehermo9/gq
filtering graphql json
Last synced: about 1 year ago
JSON representation
A fast and feature rich JSON filtering tool
- Host: GitHub
- URL: https://github.com/jorgehermo9/gq
- Owner: jorgehermo9
- License: mit
- Created: 2022-11-29T14:50:57.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-19T22:29:12.000Z (over 2 years ago)
- Last Synced: 2025-04-30T10:25:38.588Z (about 1 year ago)
- Topics: filtering, graphql, json
- Language: C++
- Homepage:
- Size: 740 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
gq
A **fast** and **feature rich** JSON filtering tool
#
FEATURES ✨
- **Filtering**: filter JSON objects getting only the fields you want, using a GraphQL-like syntax.
- **Url and file compatibility**: it can read as input a JSON file, got from a url, a file or from stdin.
- **All JSON types**: it supports all JSON types including arrays, objects...
- **Aliases**: you can use aliases to rename fields in the output file.
- **Conditions**: you can establish conditions that field's values must meet.
(To see a detailed list of available operations refer to [Operations](#operations))
- **Error proof**: (almost) all possible errors and warnings are handled and reported to the user using a custom lexer and parser.
#
INSTALLATION 🛠
...
#
USAGE 🪧
Let's see how easy is to use `gq` to filter a JSON file.
Over this JSON:
```json
{
"user": "John",
"bill": {
"purchaser": "One S.A",
"seller": "Two S.A",
"products": [
{
"name": "Product 1",
"quantity": 3,
"price": { "value": 1.0, "currency": "EUR" },
"tags": ["tag1", "tag2"]
},
{
"name": "Product 2",
"quantity": 1,
"price": { "value": 2.0, "currency": "USD" },
"tags": ["tag3"]
}
]
}
}
```
- We can use this simple graphql-like query to get only the name and price of each product:
```graphql
{
bill {
products {
name
price
}
}
}
```