1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Find And Copy A Value From Large JSON Output as a Unix TIL

This commit is contained in:
jbranchaud
2025-03-21 10:22:50 -05:00
parent 22541826d6
commit 5c9a3888fd
2 changed files with 24 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
# Find And Copy A Value From Large JSON Output
I've been using [`fx`](https://github.com/antonmedv/fx) for years as a sidekick
to [`jq`](https://jqlang.org/) when I want to explore a JSON document or JSON
output that I'm not yet familiar with. A more recent version of `fx` added the
ability to _yank_ (copy) values and keys you find in the document.
For instance, I may be looking for some info about my AWS RDS instances, so I
pipe that command to `fx`.
```bash
$ aws rds describe-db-instances --output json | fx
```
This takes a moment to process and then the `fx` viewer is populated with a
large blob of JSON. I can then hit `/` to start a document search, type in
something like `Endpoint`, and then look around for the specific key-value pair
I'm interested in.
I can then hit `y` to indicate that I want to copy the element under my cursor.
If it is a key-value pair I will then be prompted to pick whether I want the
value (`v`), the key (`k`), or the JSON path to this value (`p`).