antonmedv / fx

Terminal JSON viewer & processor
https://fx.wtf
MIT License
19.08k stars 438 forks source link

Arbitrarily long nested json shortcuts x level deep #173

Closed boulderob closed 3 years ago

boulderob commented 3 years ago

This project looks very useful. Thanks!

If I have a very deeply nested json source, is it possible with your utility to do the following and if so how:

Basically I'm trying to find a way to just skip all the stuff I don't care about and get to what I want in a rather convoluted and perhaps undocumented json structure quickly.

Regardless of whether I use a "shortcut" like sought above or some longer method to get to level 12 and the key value(s) that I want, once I get there:

Thanks

antonmedv commented 3 years ago

It’s just JavaScript) write it in js.

boulderob commented 3 years ago

Thanks for the reply.

I guess I'm having a hard time visualizing how to do this in pure js code so chaining it inline here seems only that much harder. I presume I would recursively keep a counter and just dive down x levels? How do I recursively accumulate the path though and print out the final path after the recursion is done and append the additional path I choose from x arbitrary paths after the initial recursion gets me to the level I want? I hope that makes sense

antonmedv commented 3 years ago

That’s up to you to figure it out.