pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/textproc/gron
Module Name: pkgsrc
Committed By: kim
Date: Sun Apr 20 05:56:53 UTC 2025
Added Files:
pkgsrc/textproc/gron: DESCR Makefile PLIST distinfo go-modules.mk
pkgsrc/textproc/gron/files: gron.1
Log Message:
gron: Add gron 0.7.1
gron is a tool that transforms JSON (JavaScript Object Notation) into
discrete assignments. This flattened format makes it easier to grep for
specific values within the JSON structure and clearly shows the path to
each value.
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 pkgsrc/textproc/gron/DESCR \
pkgsrc/textproc/gron/Makefile pkgsrc/textproc/gron/PLIST \
pkgsrc/textproc/gron/distinfo pkgsrc/textproc/gron/go-modules.mk
cvs rdiff -u -r0 -r1.1 pkgsrc/textproc/gron/files/gron.1
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Added files:
Index: pkgsrc/textproc/gron/DESCR
diff -u /dev/null pkgsrc/textproc/gron/DESCR:1.1
--- /dev/null Sun Apr 20 05:56:53 2025
+++ pkgsrc/textproc/gron/DESCR Sun Apr 20 05:56:52 2025
@@ -0,0 +1,9 @@
+gron is a tool that transforms JSON (JavaScript Object Notation) into
+discrete assignments. This flattened format makes it easier to grep for
+specific values within the JSON structure and clearly shows the path to
+each value.
+
+It can be useful for exploring JSON APIs, debugging, and extracting
+specific pieces of data from complex JSON documents using standard Unix
+tools like grep, sed, and awk. gron can also convert its flattened
+format back into JSON.
Index: pkgsrc/textproc/gron/Makefile
diff -u /dev/null pkgsrc/textproc/gron/Makefile:1.1
--- /dev/null Sun Apr 20 05:56:53 2025
+++ pkgsrc/textproc/gron/Makefile Sun Apr 20 05:56:52 2025
@@ -0,0 +1,22 @@
+# $NetBSD: Makefile,v 1.1 2025/04/20 05:56:52 kim Exp $
+
+DISTNAME= gron-0.7.1
+CATEGORIES= textproc
+MASTER_SITES= ${MASTER_SITE_GITHUB:=tomnomnom/}
+GITHUB_PROJECT= gron
+GITHUB_TAG= v${PKGVERSION_NOREV}
+
+MAINTAINER= pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE= https://github.com/tomnomnom/gron
+COMMENT= Transform JSON into discrete assignments for easier searching
+LICENSE= mit
+
+INSTALLATION_DIRS+= ${PKGMANDIR}/man1
+
+.include "go-modules.mk"
+
+post-install:
+ ${INSTALL_MAN} ${FILESDIR}/gron.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/
+
+.include "../../lang/go/go-module.mk"
+.include "../../mk/bsd.pkg.mk"
Index: pkgsrc/textproc/gron/PLIST
diff -u /dev/null pkgsrc/textproc/gron/PLIST:1.1
--- /dev/null Sun Apr 20 05:56:53 2025
+++ pkgsrc/textproc/gron/PLIST Sun Apr 20 05:56:52 2025
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1 2025/04/20 05:56:52 kim Exp $
+bin/gron
+man/man1/gron.1
Index: pkgsrc/textproc/gron/distinfo
diff -u /dev/null pkgsrc/textproc/gron/distinfo:1.1
--- /dev/null Sun Apr 20 05:56:53 2025
+++ pkgsrc/textproc/gron/distinfo Sun Apr 20 05:56:52 2025
@@ -0,0 +1,41 @@
+$NetBSD: distinfo,v 1.1 2025/04/20 05:56:52 kim Exp $
+
+BLAKE2s (github.com_fatih_color_@v_v1.7.0.mod) = 154726dc4d1ae892d28b47df9f01eb216e481c600878a337581435d2129c6004
+SHA512 (github.com_fatih_color_@v_v1.7.0.mod) = 2dfc66b2f6accb7ecaccc48cb3daa338173f4751d954cb2912025d881f17a7a2df0457b2d7420f2d93b50519a2437a763450c4d639a26b3289fce7bdec5bb144
+Size (github.com_fatih_color_@v_v1.7.0.mod) = 30 bytes
+BLAKE2s (github.com_fatih_color_@v_v1.7.0.zip) = 583e061a55f16d9802b707551ee3f99cd1ecfe8c4114bfa691cadf358e4df3f8
+SHA512 (github.com_fatih_color_@v_v1.7.0.zip) = 70f78081c04bdbb52e8f5d24b8926b39a28c4f069beaee0d7bf24be946f2b0ee3bc08d8ecc1305412623670e1767433a37d458df3fc849d244c63b6222f1f599
+Size (github.com_fatih_color_@v_v1.7.0.zip) = 11987 bytes
+BLAKE2s (github.com_mattn_go-colorable_@v_v0.0.9.mod) = 07a43b157b54aeabc43653c65dc7c59a9e0ddd02d00ad729fb2d584d53b61f5f
+SHA512 (github.com_mattn_go-colorable_@v_v0.0.9.mod) = 3cc3ae26618b96a0fc076b18bab6f8f0f6a1064d6a9913c1015a9867fd3571d17f5d2867d72cec008e9bc7005883a596edb21424084f82ad5b572443de90f976
+Size (github.com_mattn_go-colorable_@v_v0.0.9.mod) = 37 bytes
+BLAKE2s (github.com_mattn_go-colorable_@v_v0.0.9.zip) = d19ad8faa1905142115cef8b870923c34b4ac2436d0c8c2ce74b533660aa5174
+SHA512 (github.com_mattn_go-colorable_@v_v0.0.9.zip) = dd1763a8d04540b3e579d397fa4888c4bd8c00c3963cfcd1fe42af7c1990ef85f9a2e2fd5c5f2c7d3e6817448df5e2237241ff5a2cda651b061cc8932e0afdca
+Size (github.com_mattn_go-colorable_@v_v0.0.9.zip) = 10606 bytes
+BLAKE2s (github.com_mattn_go-isatty_@v_v0.0.4.mod) = 37ec7961d2e1e9102e227894b5db129a4beb1b4cacb699cf762deba01111dd93
+SHA512 (github.com_mattn_go-isatty_@v_v0.0.4.mod) = 00c272b4652db259c46875641b29489ecada2602e38beede8c8bd529d73b6e123bff58f8e0f8cadd2d680a6a5485aadffa448e9445548abbd2fb424b059a31e1
+Size (github.com_mattn_go-isatty_@v_v0.0.4.mod) = 34 bytes
+BLAKE2s (github.com_mattn_go-isatty_@v_v0.0.4.zip) = 96c7e635f42b45ca71410bdab26751b58922a05c822dd15c92883544b83d376e
+SHA512 (github.com_mattn_go-isatty_@v_v0.0.4.zip) = 829b0596279218a2fad36695fa42036f265ce79903a0f5aad27495dfc7c6a33e8bad32010e59f4dc6853f1e38fd9e9f635ca2f56adaf5ea47e4914f2a892d251
+Size (github.com_mattn_go-isatty_@v_v0.0.4.zip) = 7026 bytes
+BLAKE2s (github.com_nwidger_jsoncolor_@v_v0.0.0-20170215171346-75a6de4340e5.mod) = 38b9a0328f11b8ccccb2a7b1fdc9ec91bea77e12bcf293227fa337e23fd6724f
+SHA512 (github.com_nwidger_jsoncolor_@v_v0.0.0-20170215171346-75a6de4340e5.mod) =
329ac9a533db2761eaf1529b9220481ed6085d4a3e527bade850ceb20806781a1f63b7b0dd01a0cb5954ad98e4c6b6a108d3aed44fea07c452e16c2a58f91f7b
+Size (github.com_nwidger_jsoncolor_@v_v0.0.0-20170215171346-75a6de4340e5.mod) = 36 bytes
+BLAKE2s (github.com_nwidger_jsoncolor_@v_v0.0.0-20170215171346-75a6de4340e5.zip) = f8cb594c88e8aed62e546a0fdf2056a99701d3dd850b50a3d856d525a2cb887f
+SHA512 (github.com_nwidger_jsoncolor_@v_v0.0.0-20170215171346-75a6de4340e5.zip) =
f710a4372bd5a05d068084d5718e12d050a4c5ea9d7891ca1e794f385b7ab6f523fd9b93bf5cd26892d29ab61a13a53b1f4f327c250aa66b1be654cf185bb0cb
+Size (github.com_nwidger_jsoncolor_@v_v0.0.0-20170215171346-75a6de4340e5.zip) = 4964 bytes
+BLAKE2s (github.com_pkg_errors_@v_v0.8.0.mod) = ae26654fdfcb36fe7ce35e2a348782cf1a3b5c44a514b60a870dc4972267b34a
+SHA512 (github.com_pkg_errors_@v_v0.8.0.mod) = 0c156e21d35c45a89c1a1b69ff1976b4f7511b3870bf96126121f5a5effa3723eb45bf080e840d5c8b96898c65207dba83eb3e1a23668dd8a5e20ee6be775cc0
+Size (github.com_pkg_errors_@v_v0.8.0.mod) = 29 bytes
+BLAKE2s (github.com_pkg_errors_@v_v0.8.0.zip) = 980b18eb55d48c63668a7e1ba987b0a6fe74923d703de2566d0fba5d3cc7d75a
+SHA512 (github.com_pkg_errors_@v_v0.8.0.zip) = 2975fb8868fddaff560951be41194b82b631138d617705c3f6162acb76ace8697cc8ebc8f610ca1fb1a5167c6b6b0ecc87c150133a757447831463a0da18f392
+Size (github.com_pkg_errors_@v_v0.8.0.zip) = 14743 bytes
+BLAKE2s (golang.org_x_sys_@v_v0.0.0-20220412211240-33da011f77ad.mod) = 66613eb38a59b8a7f75e1aaeb294a1c4ea290d4e9ae699137566025e50ed741c
+SHA512 (golang.org_x_sys_@v_v0.0.0-20220412211240-33da011f77ad.mod) = 85e511b1261c1935f5ee4754ad31d1d946f9e10f0af9905f44c4348d6ce5104319c03fb38517dde616698f6487b0c62788cfa96bc0ffb3b6db80accd7e552655
+Size (golang.org_x_sys_@v_v0.0.0-20220412211240-33da011f77ad.mod) = 33 bytes
+BLAKE2s (golang.org_x_sys_@v_v0.0.0-20220412211240-33da011f77ad.zip) = 6687c450de7afff28bb17e83c08af8f7beb8672388deddac67ef18b7b46d08a9
+SHA512 (golang.org_x_sys_@v_v0.0.0-20220412211240-33da011f77ad.zip) = 9f20b541057ce33ac3e4b091ea81aa4f277d2abc3f68afbcc382d0e20001cfbfffbeaec18bfce97ea117fdfbe065adae2ddb8b930d5d665f05e5480897c1e7c2
+Size (golang.org_x_sys_@v_v0.0.0-20220412211240-33da011f77ad.zip) = 1741342 bytes
+BLAKE2s (gron-0.7.1.tar.gz) = 9adc3cfe7b41b50ca47ec87b21731144e3677d0a49612a9ccabc25bbadede900
+SHA512 (gron-0.7.1.tar.gz) = 8bce1915577b12cdd4105874368a8c71240a8437c402fc515598b204f8d84ade3ecc6d3bccac820683bf6fea8cf6dad2e3be7f3a3b2281af35d07524975f51ee
+Size (gron-0.7.1.tar.gz) = 340819 bytes
Index: pkgsrc/textproc/gron/go-modules.mk
diff -u /dev/null pkgsrc/textproc/gron/go-modules.mk:1.1
--- /dev/null Sun Apr 20 05:56:53 2025
+++ pkgsrc/textproc/gron/go-modules.mk Sun Apr 20 05:56:53 2025
@@ -0,0 +1,14 @@
+# $NetBSD: go-modules.mk,v 1.1 2025/04/20 05:56:53 kim Exp $
+
+GO_MODULE_FILES+= github.com/fatih/color/@v/v1.7.0.mod
+GO_MODULE_FILES+= github.com/fatih/color/@v/v1.7.0.zip
+GO_MODULE_FILES+= github.com/mattn/go-colorable/@v/v0.0.9.mod
+GO_MODULE_FILES+= github.com/mattn/go-colorable/@v/v0.0.9.zip
+GO_MODULE_FILES+= github.com/mattn/go-isatty/@v/v0.0.4.mod
+GO_MODULE_FILES+= github.com/mattn/go-isatty/@v/v0.0.4.zip
+GO_MODULE_FILES+= github.com/nwidger/jsoncolor/@v/v0.0.0-20170215171346-75a6de4340e5.mod
+GO_MODULE_FILES+= github.com/nwidger/jsoncolor/@v/v0.0.0-20170215171346-75a6de4340e5.zip
+GO_MODULE_FILES+= github.com/pkg/errors/@v/v0.8.0.mod
+GO_MODULE_FILES+= github.com/pkg/errors/@v/v0.8.0.zip
+GO_MODULE_FILES+= golang.org/x/sys/@v/v0.0.0-20220412211240-33da011f77ad.mod
+GO_MODULE_FILES+= golang.org/x/sys/@v/v0.0.0-20220412211240-33da011f77ad.zip
Index: pkgsrc/textproc/gron/files/gron.1
diff -u /dev/null pkgsrc/textproc/gron/files/gron.1:1.1
--- /dev/null Sun Apr 20 05:56:53 2025
+++ pkgsrc/textproc/gron/files/gron.1 Sun Apr 20 05:56:53 2025
@@ -0,0 +1,510 @@
+.\" Automatically generated by Pandoc 2.17.1.1
+.\"
+.\" Define V font for inline verbatim, using C font in formats
+.\" that render this, and otherwise B font.
+.ie "\f[CB]x\f[]"x" \{\
+. ftr V B
+. ftr VI BI
+. ftr VB B
+. ftr VBI BI
+.\}
+.el \{\
+. ftr V CR
+. ftr VI CI
+. ftr VB CB
+. ftr VBI CBI
+.\}
+.TH "GRON" "1" "April 2022" "0.7.1" "User Commands"
+.hy
+.SH NAME
+.PP
+\f[B]gron\f[R] - transform JSON into discrete, greppable assignments
+.SH SYNOPSIS
+.PP
+\f[B]gron\f[R] [\f[I]OPTIONS\f[R]] [\f[I]FILE\f[R]|\f[I]URL\f[R]]
+.PP
+\f[B]gron\f[R] \f[B]\[en]-version\f[R]
+.PP
+\f[B]gron\f[R] \f[B]\[en]-help\f[R]
+.SH DESCRIPTION
+.PP
+\f[B]gron\f[R] transforms JSON into discrete assignments to make it
+easier to \f[B]grep\f[R] for what you want and see the absolute `path'
+to it.
+It eases the exploration of APIs that return large blobs of JSON but
+have terrible documentation.
+.SH OPTIONS
+.TP
+-u, --ungron
+reverse the operation (turn assignments back into JSON)
+.TP
+-v, --values
+print just the values of provided assignments
+.TP
+-c, --colorize
+colorize output (default on tty)
+.TP
+-m, --monochrome
+monochrome (don\[cq]t colorize output)
+.TP
+-s, --stream
+treat each line of input as a separate JSON object
+.TP
+-k, --insecure
+disable certificate validation
+.TP
+-j, --json
+represent gron data as JSON stream
+.TP
+--no-sort
+don\[cq]t sort output (faster)
+.TP
+--version
+print version information
+.SH BASIC USAGE
+.PP
+Get JSON from a file:
+.IP
+.nf
+\f[C]
+$ gron testdata/two.json
+json = {};
+json.contact = {};
+json.contact.email = \[dq]mail\[at]tomnomnom.com\[dq];
+json.contact.twitter = \[dq]\[at]TomNomNom\[dq];
+json.github = \[dq]https://github.com/tomnomnom/\[dq];
+json.likes = [];
+json.likes[0] = \[dq]code\[dq];
+json.likes[1] = \[dq]cheese\[dq];
+json.likes[2] = \[dq]meat\[dq];
+json.name = \[dq]Tom\[dq];
+\f[R]
+.fi
+.PP
+From a URL:
+.IP
+.nf
+\f[C]
+$ gron http://headers.jsontest.com/
+json = {};
+json.Host = \[dq]headers.jsontest.com\[dq];
+json[\[dq]User-Agent\[dq]] = \[dq]gron/0.1\[dq];
+json[\[dq]X-Cloud-Trace-Context\[dq]] = \[dq]6917a823919477919dbc1523584ba25d/11970839830843610056\[dq];
+\f[R]
+.fi
+.PP
+Or from \f[V]STDIN\f[R]:
+.IP
+.nf
+\f[C]
+$ curl -s http://headers.jsontest.com/ | gron
+json = {};
+json.Accept = \[dq]*/*\[dq];
+json.Host = \[dq]headers.jsontest.com\[dq];
+json[\[dq]User-Agent\[dq]] = \[dq]curl/7.43.0\[dq];
+json[\[dq]X-Cloud-Trace-Context\[dq]] = \[dq]c70f7bf26661c67d0b9f2cde6f295319/13941186890243645147\[dq];
+\f[R]
+.fi
+.PP
+Grep for something and easily see the path to it:
+.IP
+.nf
+\f[C]
+$ gron testdata/two.json | grep twitter
+json.contact.twitter = \[dq]\[at]TomNomNom\[dq];
+\f[R]
+.fi
+.PP
+\f[V]gron\f[R] makes diffing JSON easy too:
+.IP
+.nf
+\f[C]
+$ diff <(gron two.json) <(gron two-b.json)
+3c3
+< json.contact.email = \[dq]mail\[at]tomnomnom.com\[dq];
+---
+> json.contact.email = \[dq]contact\[at]tomnomnom.com\[dq];
+\f[R]
+.fi
+.PP
+The output of \f[V]gron\f[R] is valid JavaScript:
+.IP
+.nf
+\f[C]
+$ gron testdata/two.json > tmp.js
+$ echo \[dq]console.log(json);\[dq] >> tmp.js
+$ nodejs tmp.js
+{ contact: { email: \[aq]mail\[at]tomnomnom.com\[aq], twitter: \[aq]\[at]TomNomNom\[aq] },
+ github: \[aq]https://github.com/tomnomnom/\[aq],
+ likes: [ \[aq]code\[aq], \[aq]cheese\[aq], \[aq]meat\[aq] ],
+ name: \[aq]Tom\[aq] }
+\f[R]
+.fi
+.PP
+It\[cq]s also possible to obtain the \f[V]gron\f[R] output as JSON
+stream via the \f[V]--json\f[R] switch:
+.IP
+.nf
+\f[C]
+$ curl -s http://headers.jsontest.com/ | gron --json
+[[],{}]
+[[\[dq]Accept\[dq]],\[dq]*/*\[dq]]
+[[\[dq]Host\[dq]],\[dq]headers.jsontest.com\[dq]]
+[[\[dq]User-Agent\[dq]],\[dq]curl/7.43.0\[dq]]
+[[\[dq]X-Cloud-Trace-Context\[dq]],\[dq]c70f7bf26661c67d0b9f2cde6f295319/13941186890243645147\[dq]]
+\f[R]
+.fi
+.SH UNGRONNING
+.PP
+\f[V]gron\f[R] can also turn its output back into JSON:
+.IP
+.nf
+\f[C]
+$ gron testdata/two.json | gron -u
+{
+ \[dq]contact\[dq]: {
+ \[dq]email\[dq]: \[dq]mail\[at]tomnomnom.com\[dq],
+ \[dq]twitter\[dq]: \[dq]\[at]TomNomNom\[dq]
+ },
+ \[dq]github\[dq]: \[dq]https://github.com/tomnomnom/\[dq],
+ \[dq]likes\[dq]: [
+ \[dq]code\[dq],
+ \[dq]cheese\[dq],
+ \[dq]meat\[dq]
+ ],
+ \[dq]name\[dq]: \[dq]Tom\[dq]
+}
+\f[R]
+.fi
+.PP
+This means you use can use \f[V]gron\f[R] with \f[V]grep\f[R] and other
+tools to modify JSON:
+.IP
+.nf
+\f[C]
+$ gron testdata/two.json | grep likes | gron --ungron
+{
+ \[dq]likes\[dq]: [
+ \[dq]code\[dq],
+ \[dq]cheese\[dq],
+ \[dq]meat\[dq]
+ ]
+}
+\f[R]
+.fi
+.PP
+or
+.IP
+.nf
+\f[C]
+$ gron --json testdata/two.json | grep likes | gron --json --ungron
+{
+ \[dq]likes\[dq]: [
+ \[dq]code\[dq],
+ \[dq]cheese\[dq],
+ \[dq]meat\[dq]
+ ]
+}
+\f[R]
+.fi
+.PP
+To preserve array keys, arrays are padded with \f[V]null\f[R] when
+values are missing:
+.IP
+.nf
+\f[C]
+$ gron testdata/two.json | grep likes | grep -v cheese
+json.likes = [];
+json.likes[0] = \[dq]code\[dq];
+json.likes[2] = \[dq]meat\[dq];
+$ gron testdata/two.json | grep likes | grep -v cheese | gron --ungron
+{
+ \[dq]likes\[dq]: [
+ \[dq]code\[dq],
+ null,
+ \[dq]meat\[dq]
+ ]
+}
+\f[R]
+.fi
+.SH ADVANCED USAGE
+.PP
+Although gron\[cq]s primary purpose is API discovery, when combined with
+other tools like \f[V]grep\f[R] it can do some interesting things.
+.PP
+As an exercise, let\[cq]s try to mimic some of the examples from the jq
+tutorial (https://stedolan.github.io/jq/tutorial/).
+.RS
+.PP
+Disclaimer: munging data on the command line with gron can be useful,
+but using tools like \f[V]grep\f[R] and \f[V]sed\f[R] to manipulate the
+data is error-prone and shouldn\[cq]t be relied on in scripts.
+.RE
+.PP
+Get the last 5 commits from the gron repo:
+.IP
+.nf
+\f[C]
+$ gron \[dq]https://api.github.com/repos/tomnomnom/gron/commits?per_page=5\[dq]
+json = [];
+json[0] = {};
+json[0].author = {};
+json[0].author.avatar_url = \[dq]https://avatars.githubusercontent.com/u/58276?v=3\[dq];
+json[0].author.events_url = \[dq]https://api.github.com/users/tomnomnom/events{/privacy}\[dq];
+\&...
+json[4].parents[0].html_url = \[dq]https://github.com/tomnomnom/gron/commit/cbcad2299e55c28a9922776e58b2a0b5a0f05016\[dq];
+json[4].parents[0].sha = \[dq]cbcad2299e55c28a9922776e58b2a0b5a0f05016\[dq];
+json[4].parents[0].url = \[dq]https://api.github.com/repos/tomnomnom/gron/commits/cbcad2299e55c28a9922776e58b2a0b5a0f05016\[dq];
+json[4].sha = \[dq]91b204972e63a1166c9d148fbbfd839f8697f91b\[dq];
+json[4].url = \[dq]https://api.github.com/repos/tomnomnom/gron/commits/91b204972e63a1166c9d148fbbfd839f8697f91b\[dq];
+\f[R]
+.fi
+.PP
+To make the rest of this a little more readable, let\[cq]s add an alias
+for that:
+.IP
+.nf
+\f[C]
+$ alias ggh=\[aq]gron \[dq]https://api.github.com/repos/tomnomnom/gron/commits?per_page=5\[dq]\[aq]
+\f[R]
+.fi
+.PP
+Extract just the first commit using \f[V]fgrep \[dq]json[0]\[dq]\f[R]:
+.IP
+.nf
+\f[C]
+$ ggh | fgrep \[dq]json[0]\[dq]
+json[0] = {};
+json[0].author = {};
+json[0].author.avatar_url = \[dq]https://avatars.githubusercontent.com/u/58276?v=3\[dq];
+json[0].author.events_url = \[dq]https://api.github.com/users/tomnomnom/events{/privacy}\[dq];
+json[0].author.followers_url = \[dq]https://api.github.com/users/tomnomnom/followers\[dq];
+\&...
+json[0].parents[0].html_url = \[dq]https://github.com/tomnomnom/gron/commit/48aba5325ece087ae24ab72684851cbe77ce8311\[dq];
+json[0].parents[0].sha = \[dq]48aba5325ece087ae24ab72684851cbe77ce8311\[dq];
+json[0].parents[0].url = \[dq]https://api.github.com/repos/tomnomnom/gron/commits/48aba5325ece087ae24ab72684851cbe77ce8311\[dq];
+json[0].sha = \[dq]7da81e29c27241c0a5c2e5d083ddebcfcc525908\[dq];
+json[0].url = \[dq]https://api.github.com/repos/tomnomnom/gron/commits/7da81e29c27241c0a5c2e5d083ddebcfcc525908\[dq];
+\f[R]
+.fi
+.PP
+Get just the committer\[cq]s name and the commit message using
+\f[V]egrep \[dq](committer.name|commit.message)\[dq]\f[R]:
+.IP
+.nf
+\f[C]
+$ ggh | fgrep \[dq]json[0]\[dq] | egrep \[dq](committer.name|commit.message)\[dq]
+json[0].commit.committer.name = \[dq]Tom Hudson\[dq];
+json[0].commit.message = \[dq]Adds 0.1.7 to changelog\[dq];
+\f[R]
+.fi
+.PP
+Turn the result back into JSON using \f[V]gron --ungron\f[R]:
+.IP
+.nf
+\f[C]
+$ ggh | fgrep \[dq]json[0]\[dq] | egrep \[dq](committer.name|commit.message)\[dq] | gron --ungron
+[
+ {
+ \[dq]commit\[dq]: {
+ \[dq]committer\[dq]: {
+ \[dq]name\[dq]: \[dq]Tom Hudson\[dq]
+ },
+ \[dq]message\[dq]: \[dq]Adds 0.1.7 to changelog\[dq]
+ }
+ }
+]
+\f[R]
+.fi
+.PP
+gron preserves the location of values in the JSON, but you can use
+\f[V]sed\f[R] to remove keys from the path:
+.IP
+.nf
+\f[C]
+$ ggh | fgrep \[dq]json[0]\[dq] | egrep \[dq](committer.name|commit.message)\[dq] | sed -r \[dq]s/(commit|committer)\[rs].//g\[dq]
+json[0].name = \[dq]Tom Hudson\[dq];
+json[0].message = \[dq]Adds 0.1.7 to changelog\[dq]
+\f[R]
+.fi
+.PP
+With those keys removed, the result is a `flattened' object, which looks
+much cleaner when turned back into JSON with \f[V]gron --ungron\f[R]:
+.IP
+.nf
+\f[C]
+$ ggh | fgrep \[dq]json[0]\[dq] | egrep \[dq](committer.name|commit.message)\[dq] | sed -r \[dq]s/(commit|committer)\[rs].//g\[dq] | gron --ungron
+[
+ {
+ \[dq]message\[dq]: \[dq]Adds 0.1.7 to changelog\[dq],
+ \[dq]name\[dq]: \[dq]Tom Hudson\[dq]
+ }
+]
+\f[R]
+.fi
+.PP
+Removing the \f[V]fgrep \[dq]json[0]\[dq]\f[R] from the pipeline means
+we do the same for all commits:
+.IP
+.nf
+\f[C]
+$ ggh | egrep \[dq](committer.name|commit.message)\[dq] | sed -r \[dq]s/(commit|committer)\[rs].//g\[dq] | gron --ungron
+[
+ {
+ \[dq]message\[dq]: \[dq]Adds 0.1.7 to changelog\[dq],
+ \[dq]name\[dq]: \[dq]Tom Hudson\[dq]
+ },
+ {
+ \[dq]message\[dq]: \[dq]Refactors natural sort to actually work + be more readable\[dq],
+ \[dq]name\[dq]: \[dq]Tom Hudson\[dq]
+ },
+\&...
+\f[R]
+.fi
+.PP
+To include the \f[V]html_url\f[R] key for each commit\[cq]s parents, all
+we need to do is add \f[V]parents.*html_url\f[R] into our call to
+\f[V]egrep\f[R]:
+.IP
+.nf
+\f[C]
+$ ggh | egrep \[dq](committer.name|commit.message|parents.*html_url)\[dq] | sed -r \[dq]s/(commit|committer)\[rs].//g\[dq]
+json[0].name = \[dq]Tom Hudson\[dq];
+json[0].message = \[dq]Adds 0.1.7 to changelog\[dq];
+json[0].parents[0].html_url = \[dq]https://github.com/tomnomnom/gron/commit/48aba5325ece087ae24ab72684851cbe77ce8311\[dq];
+json[1].name = \[dq]Tom Hudson\[dq];
+json[1].message = \[dq]Refactors natural sort to actually work + be more readable\[dq];
+json[1].parents[0].html_url = \[dq]https://github.com/tomnomnom/gron/commit/3eca8bf5e07151f077cebf0d942c1fa8bc51e8f2\[dq];
+\&...
+\f[R]
+.fi
+.PP
+To make the structure more like that in the final example in the
+\f[V]jq\f[R] tutorial, we can use
+\f[V]sed -r \[dq]s/\[rs].html_url//\[dq]\f[R] to remove the
+\f[V].html_url\f[R] part of the path:
+.IP
+.nf
+\f[C]
+$ ggh | egrep \[dq](committer.name|commit.message|parents.*html_url)\[dq] | sed -r \[dq]s/(commit|committer)\[rs].//g\[dq] | sed -r \[dq]s/\[rs].html_url//\[dq]
+json[0].name = \[dq]Tom Hudson\[dq];
+json[0].message = \[dq]Adds 0.1.7 to changelog\[dq];
+json[0].parents[0] = \[dq]https://github.com/tomnomnom/gron/commit/48aba5325ece087ae24ab72684851cbe77ce8311\[dq];
+json[1].name = \[dq]Tom Hudson\[dq];
+json[1].message = \[dq]Refactors natural sort to actually work + be more readable\[dq];
+json[1].parents[0] = \[dq]https://github.com/tomnomnom/gron/commit/3eca8bf5e07151f077cebf0d942c1fa8bc51e8f2\[dq];
+\&...
+\f[R]
+.fi
+.PP
+And, of course, the statements can be turned back into JSON with
+\f[V]gron --ungron\f[R]:
+.IP
+.nf
+\f[C]
+$ ggh | egrep \[dq](committer.name|commit.message|parents.*html_url)\[dq] | sed -r \[dq]s/(commit|committer)\[rs].//g\[dq] | sed -r \[dq]s/\[rs].html_url//\[dq] | gron --ungron
+[
+ {
+ \[dq]message\[dq]: \[dq]Adds 0.1.7 to changelog\[dq],
+ \[dq]name\[dq]: \[dq]Tom Hudson\[dq],
+ \[dq]parents\[dq]: [
+ \[dq]https://github.com/tomnomnom/gron/commit/48aba5325ece087ae24ab72684851cbe77ce8311\[dq]
+ ]
+ },
+ {
+ \[dq]message\[dq]: \[dq]Refactors natural sort to actually work + be more readable\[dq],
+ \[dq]name\[dq]: \[dq]Tom Hudson\[dq],
+ \[dq]parents\[dq]: [
+ \[dq]https://github.com/tomnomnom/gron/commit/3eca8bf5e07151f077cebf0d942c1fa8bc51e8f2\[dq]
+ ]
+ },
+\&...
+\f[R]
+.fi
+.SH EXAMPLES
+.PP
+Read from a local file/network:
+.IP
+.nf
+\f[C]
+$ gron /tmp/apiresponse.json
+$ gron http://jsonplaceholder.typicode.com/users/1
+\f[R]
+.fi
+.PP
+Retrieve remote JSON and pipe through gron:
+.IP
+.nf
+\f[C]
+$ curl -s http://jsonplaceholder.typicode.com/users/1 | gron
+\f[R]
+.fi
+.PP
+Flatten and filter JSON through gron, before turning result back into
+JSON:
+.IP
+.nf
+\f[C]
+$ gron http://jsonplaceholder.typicode.com/users/1 | grep company | gron --ungron
+\f[R]
+.fi
+.SH TIPS
+.PP
+It\[cq]s recommended that you alias \f[V]ungron\f[R] or \f[V]norg\f[R]
+(or both!)
+to \f[V]gron --ungron\f[R].
+Put something like this in your shell profile (e.g.\ in
+\f[V]\[ti]/.bashrc\f[R]):
+.IP
+.nf
+\f[C]
+alias norg=\[dq]gron --ungron\[dq]
+alias ungron=\[dq]gron --ungron\[dq]
+\f[R]
+.fi
+.PP
+Or you could create a shell script in your
+$PATH named \[ga]ungron\[ga] or \[ga]norg\[ga] to affect all users: \[ga]\[ga]\[ga] gron --ungron \[dq]$\[at]\[rq]
+\[ga]\[ga]\[ga]
+.SH EXIT STATUS
+.PP
+0 OK
+.PD 0
+.P
+.PD
+1 Failed to open file
+.PD 0
+.P
+.PD
+2 Failed to read input
+.PD 0
+.P
+.PD
+3 Failed to form statements
+.PD 0
+.P
+.PD
+4 Failed to fetch URL
+.PD 0
+.P
+.PD
+5 Failed to parse statements
+.PD 0
+.P
+.PD
+6 Failed to encode JSON
+.SH REPORTING BUGS
+.PP
+Upstream bug tracker: https://github.com/tomnomnom/gron/issues
+.SH COPYRIGHT
+.PP
+Copyright (c) 2016 Tom Hudson
+.SH AUTHOR
+.PP
+This manual page is based on the gron documentation.
+It was created by Nick Morrott <nickm%debian.org@localhost> for the Debian
+GNU/Linux system, but may be used by others
+.SH SEE ALSO
+.PP
+\f[B]grep(1)\f[R], \f[B]ack(1)\f[R], \f[B]ag(1)\f[R], \f[B]rg(1)\f[R],
+\f[B]jq(1)\f[R]
Home |
Main Index |
Thread Index |
Old Index