Comments (4)
Just to document this somewhere, you can use jq 'del(.[][] | nulls)'
to remove the nulls in case you need it.
Using the example from the the README:
echo '{ "contact": { "email": "[email protected]", "twitter": "@TomNomNom" }, "github": "https://github.com/tomnomnom/", "likes": [ "code", "cheese", "meat" ], "name": "Tom" }' | gron | grep likes | grep -v cheese | gron --ungron | jq 'del(.[][] | nulls)'
{
"likes": [
"code",
"meat"
]
}
from gron.
That would be great if all I cared about was nulls in nested arrays two levels deep. Unfortunately it doesn't work if you encapsulate the entire source text in a new top level JSON object:
$ echo '{ "wrapper": { "contact": { "email": "[email protected]", "twitter": "@TomNomNom" }, "github": "https://github.com/tomnomnom/", "likes": [ "code", "cheese", "meat" ], "name": "Tom" } }' | gron | grep likes | grep -v cheese | gron --ungron | jq 'del(.[][] | nulls)'
{
"wrapper": {
"likes": [
"code",
null,
"meat"
]
}
}
Unless it's possible to exclude nulls recursively. Maybe I could use the walk
command in jq
1.6, but I was hoping for something a bit more out of the box in gron
.
from gron.
from gron.
Would be interesting if ngron
could generate objects instead of sparse arrays.
from gron.
Related Issues (20)
- --no-sort option is unstable HOT 5
- Ungron doesn't respect --no-sort option HOT 1
- Output format HOT 12
- more tollerance when parsing
- Remove this HOT 1
- Export functions? HOT 1
- asdf gron
- Colour - Support Highlighting when Ungronning from grep.
- Bash completions HOT 1
- gron will fail to link at runtime once OpenBSD removes syscall(2)
- Auto-provide command line completions
- panic with --values HOT 1
- `--no-sort` should apply on each line when using `-s`
- github client downloa
- Feature Request: Support for Ruby syntax HOT 4
- failed to form statements: invalid character 'ï' looking for beginning of value HOT 3
- Binary builds broken?? HOT 4
- Add release for armv6l
- Special-case `new Array()` and `new Object`
- v0.7.1 does not report its own version HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gron.