Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A Go tool to convert gron output to useful jq commands.

NotificationsYou must be signed in to change notification settings

bbbbbrie/grontojq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

📦 Installation

go install github.com/bbbbbrie/grontojq@latest

That should put thegrontojq executable in$GOBIN. If that's in$PATH,which grontojq should point you to it.

ℹ️ How one might usegrontojq

This is a Go tool that convertsgron output intojq commands. I wrote this to solve a specific problem I had and as an excuse to write in Go again.

I typically usegron to help build thejq command I want to use for whatever I'm trying to do. While--ungron is nice, I don't want to havegron as a dependency in pipelines or other places where I'm making use ofjq. I usegron to help build thejq commands. Once I have them, I use justjq for the actual parsing.

You can pipe the output ofgron in togrontojq. Here's how I thinkgrontojq is most useful:

First, you'll usegron cats.json to explore the JSON file you're interested in:

# gron cats.json...json.catDescriptions[10] = {};json.catDescriptions[10].emoji = "😽";json.catDescriptions[10].word = "Charming";json.catDescriptions[11] = {};json.catDescriptions[11].emoji = "😈";json.catDescriptions[11].word = "Mischievous";

Next, you'll do something likegron cats.json | grep 11 | grep word to pick the exact line you're interested in:

# gron cats.json | grep 11 | grep wordjson.catDescriptions[11].word = "Mischievous";

Then, you'll pass that output togrontojq:

# gron cats.json | grep 11 | grep word | grontojqjq '.catDescriptions[11].word'

You can copy this from your terminal or usepbcopy or similar to copy it straight to your clipboard with something likegron cats.json | grep 11 | grep word | grontojq | pbcopy.

Finally, you'll take the output fromgrontojq and use it to parse the file more elegantly:

jq '.catDescriptions[11].word' cats.json

🐈‍⬛ Why?

This makes it a tiny bit easier to go fromgron output tojq filter -- especially if piping to something likegrontojq is easy to add to your terminal muscle memory. I'd alias it to something likeg2jq or similar to make that even easier.

About

A Go tool to convert gron output to useful jq commands.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp