Jqjq: Jq Implementation of Jq
github.com
github.com
https://github.com/xoreaxeaxeax/movfuscator
Presentation of idea:
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.My problem is the infrequency with which I need to use jq means I don't create a good learning feedback loop. The last time I used it though, I was able to walk down a decently complicated structure (indexed val in an array in a key in a hash in an array) and extract the data I wanted only having to google once. Like awk, though, I know there's a world of functionality I'm just not using.
Some collection of typical problems and solutions would help I guess.
The IMO not so good parts of that page are
- Quite a few section headers don’t make sense to novices
- I think the table of contents would be better if it had subheaders, ideally with one-line descriptions of the features (that probably would solve the issue above)
- not every section has examples
- some examples use fairly advanced features, making them harder to understand then necessary
- jello (PyPI) - yamlpath (PyPI) - dasel
I tried, more than once, but I guess I'm not smart enough.
$ ./jqjq "eval($(jq -Rs . jqjq.jq)+.)" <<< '"eval(\"def f:
1,8; [f,f] | map(.+105) | implode\")"'
"jqjq"
But running jqjq in jqjq in jqjq runs out of memory so don't know if that works yet :)At least xmlstarlet has xslt for language.
Now after using jq a lot think about it the other way around. The language itself is no that tied to JSON, it can be used for more things with other types then just JSON. If you interested have a look at https://github.com/wader/fq where i've tried to expand on it.
I am confused by this sentence. Wasn't the entire premise that js is NOT installed?
exodus jq | ssh my-server
locally, and then immediately have access to jq on the server. I personally find it very useful when working with servers or containers that have limited package repositories or where I don't have root access.That's really neat.
Exodus – relocation of Linux binaries–and all of their deps–without containers
https://news.ycombinator.com/item?id=29446297
(307 points, 65 comments)
cat big.json | python3 -m json.tool
or python3 -m json.tool big.json ssh badly-managed-server cat file | jq .
Problem solved !I actually made a wrapper that just guesses (based on which parser returns error basically) type of serializing and then displays it nicely.
Then again, why not scp the file to local? Bandwidth usage isn’t good for the environment.
sshmount () {
SSHFS_SERVER_DIR='/home/user'
if [ "z$1" = "z" ]
then
echo "specify server [server_dir]"
return
fi
SSHFS_SERVER=$1
if [ "z$2" != "z" ]
then
SSHFS_SERVER_DIR=$2
fi
SSHFS_TARGET_DIR="/home/user/mnt/$SSHFS_SERVER"
echo "Mounting $SSHFS_SERVER:$SSHFS_SERVER_DIR into $SSHFS_TARGET_DIR"
mkdir -p $SSHFS_TARGET_DIR
sshfs -o idmap=user -o allow_other -o kernel_cache $SSHFS_SERVER:$SSHFS_SERVER_DIR $SSHFS_TARGET_DIR && cd $SSHFS_TARGET_DIR
}
sshmount servername
will mount server's home in directory /home/user/mnt/servername, second parameter changes the server dir to specified onehttps://stackoverflow.com/a/70614580/1507124
it's not full pretty, rather just newline delimits arrays. Incidentally, it's much faster than jq. Probably wouldn't use it for anything serious