https://github.com/danvk/jss
JSON processing command line tool based on JSONSelect (CSS-like selectors for JSON)
https://github.com/danvk/jss
Last synced: 5 months ago
JSON representation
JSON processing command line tool based on JSONSelect (CSS-like selectors for JSON)
- Host: GitHub
- URL: https://github.com/danvk/jss
- Owner: danvk
- License: apache-2.0
- Created: 2014-10-13T21:25:33.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-09-28T15:31:41.000Z (almost 11 years ago)
- Last Synced: 2025-04-03T19:22:20.586Z (over 1 year ago)
- Language: Python
- Size: 212 KB
- Stars: 43
- Watchers: 3
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/danvk/jss)
jss
===
jss is a JSON processing command line tool (like jq).
Unlike [jq](http://stedolan.github.io/jq/), its selection language is
[JSONSelect](http://jsonselect.org/#overview), which is based on CSS
selectors. No need to learn an ad-hoc language for processing your JSON files.
Just use one you already know! Your time with jss won't be wasted—it will make
you better at writing CSS selectors.
Usage
-------
Install:
$ pip install jss
Sample JSON file for demos:
$ cat file.json
```json
{
"foo": [
"bar",
{
"baz": "quux"
}
],
"wut": {
"name": "foo",
"metadata": {
"owner": "danvk",
"blah": "whatever"
}
},
"name": "dan"
}
```
Pull out all values with key "name", from anywhere in the JSON.
$ jss .name file.json
```json
"foo"
"dan"
```
Remove fields named "metadata", wherever they occur (JSON→JSON transform):
$ jss -v .metadata file.json
```json
{
"foo": [
"bar",
{
"baz": "quux"
}
],
"wut": {
"name": "foo"
},
"name": "dan"
}
```
Keep only fields named "name", plus their ancestors (JSON→JSON transform):
$ jss -k .name file.json
```json
{
"wut": {
"name": "foo"
},
"name": "dan"
}
```
Keep only top-level entries with "whatever" in some value underneath them (JSON→JSON transform using jQuery-style selectors):
$ jss -k ':root>*:has(:contains("whatever"))' file.json
```json
{
"wut": {
"name": "foo",
"metadata": {
"owner": "danvk",
"blah": "whatever"
}
}
}
```