I wrote a tutorial for jp
my bash-based json processor. https://github.com/dnmfarrell/jp#tutorial
I'm trying to make it easy for newcomers to learn something useful and accomplish something right away (even if the Venn diagram of users with bash who need to validate/transform json and don't already use jq is small). I'd appreciate any feedback anyone has. Thanks!
Looks interesting, but hard for me to figure out how to program it. I prefer functional abstractions, Modeling a stack in my head feels inherently difficult to learn. Most JSON transforms I want to do is to flatten and pack things. I dunno how to do that. I look at map with fear. I don't think it can handle what I would want it for.
📷 image.png
Hey thanks for taking a look. I agree, the stack concept is more abstract than passing explicit arguments. Do you have an example json transformation I could try? I'm curious if jp is missing a feature or if there is a use case it doesn't serve.
OK here is my last usages of jq
gcloud container images list-tags eu.gcr.io/endpointservice/serversidecells \
--project=endpointservice --limit 1 --format=json | jq '.[0].tags[0]' --raw-output
which is '.[0].tags[0]' against:
[
{
"digest": "sha256:7c470e2220c6e3160b88d88db9dc5bd121203e7bd2a734bda2a43d7af0277a0c",
"tags": [
"20211217_143425"
],
"timestamp": {
"datetime": "2021-12-17 14:36:54+01:00",
"day": 17,
"fold": 0,
"hour": 14,
"microsecond": 0,
"minute": 36,
"month": 12,
"second": 54,
"year": 2021
}
}
]
so i am really just reading first tags value via some kind of path based index