2 ms·
gron is great, i have this in my init.jq file for fq (https://github.com/wader/fq https://github.com/wader/fq). Sadly jq lacks a path_to_expr function so a bit
by wwader 4y ago
gron is great, i have this in my init.jq file for fq (https://github.com/wader/fq https://github.com/wader/fq). Sadly jq lacks a path_to_expr function so a bit harder to do it with that.
def gron:
( path(..) as $p
| getpath($p)
| scalars
| "\($p | path_to_expr) = \(tojson)"
| println
);
Ex:
$ fq gron <<< '{"a": [1,2,{"b": 3}]}'
.a[0] = 1
.a[1] = 2
.a[2].b = 3
Great for copy/paste into other expressions when poking around.