8 ms·
Jqjq: Jq Implementation of Jq
- zegl 4y agoThis is genius and horrifying at the same time, I love it!
- orf 4y ago> Your scientists were so preoccupied with whether they could, they didn't stop to think if they should
- deleted 4y ago[deleted]
- deleted 4y ago[deleted]
- andrewfromx 4y agovery impressive. I like how github even says language: jq 100%.
- deleted 4y ago[deleted]
- raverbashing 4y agoJq is ok, but the language is awfully unintuitive. It's also not very user-friendly. I've been using gojq with better success
- howeyc 4y agoI just use gron then grep for what I'm looking for.
- dtech 4y agoDoes it do more than just grep? That's awfully limited compared to what jq can do. I personally like jless for just searching and exploring.
- wwader 4y agogron 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.
- stevage 4y agoYeah, I like the design goals, I just found the solution was worse than the problem it was solving.
- secondcoming 4y agoI'll never be intelligent enough to use jq properly.
- xendo 4y agoI’ve been using ‚gron’ with good results
- pfarrell 4y agoHow is gojq different? Cursory look at the README and it seems like it implements the same language. 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.
- sitkack 4y agoYou should checkout gron, it is great at flattening fragments of json. https://github.com/tomnomnom/gron https://github.com/tomnomnom/gron
- lathiat 4y agoI have started using gron to understand the json structure to then write jq. Other times it does the job alone. It’s great.
- sitkack 4y agoYou can pipe the output of gron into fzf, it makes it kinda nice for perusing the flattened json.
- pfarrell 4y agoTIL. Thank you! I took a look and will definitely incorporate this in my work. Definitely a good idea.
- zikduruqe 4y agoAnytime jq is mentioned, gron should be mentioned shortly thereafter. It is a wonderful tool.
- lapser 4y agoIt is indeed a reimplementation of jq in go, and the reason I use it over jq is many, one of which is that it produces more helpful error messages. In fact, I've moved jq to ojq (sometimes I want to check compatibility), and ln -fs gojq jq.
- vbezhenar 4y agoI feel like it's OK if you use it often, but when you need it once a year, I'm spending too much time trying to figure it out. Some collection of typical problems and solutions would help I guess.
- delecti 4y agoI use it a bunch to string together web APIs, and you're absolutely right. The longer I go relying on my library of pre-written strings of commands, the harder it is to write a new one. And you're right again with your second point, because that same library makes for great reference material for myself.
- Someone 4y agoThe manual (https://stedolan.github.io/jq/manual/ https://stedolan.github.io/jq/manual/) somewhat provides that. Quite a few sections have helpful examples, with links to the sandbox at jqplay.org. 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
- AndyKluger 4y agoI see folks have mentioned gron, and I also want to suggest: - jello (PyPI) - yamlpath (PyPI) - dasel
- sph 4y agojq is not OK for that exact reason. It's like sendmail, dividing the world into people smart yet obtuse enough to sit and learn its idiosyncrasies, and regular people that go mad and claw their eyes out whenever they try. I tried, more than once, but I guess I'm not smart enough.
- nusaru 4y agoTIL GitHub highlights **Warning** in blockquote https://github.com/community/community/discussions/16925 https://github.com/community/community/discussions/16925
- ducktective 4y agoIs it slower than the reference Jq written in C?
- kenoph 4y agoImpressive. Someone should do jq-jit too. I briefly looked into it and it seems like it would be _a lot_ of effort :/
- olooney 4y agoHas this happened to you? You're logged into a remote server and trying to read a config file or log file. The problem is its in a minified JSON format and looks like a solid wall of noise when you try to use `less`. You reach for your go-to JSON swiss army knife `jq` but it's not installed! You don't have root access to install it via `apt-get` so you need a script you can run locally. Just copy the `jqjq` and `jqjq.jq` files to your local directory, and now you can access the full power of jq just by running `./jqjq`. Problem solved! And the best part is that the only dependency is `jq`, which should be installed pretty much everywhere.
- rpadovani 4y ago> And the best part is that the only dependency is `jq`, which should be installed pretty much everywhere. I am confused by this sentence. Wasn't the entire premise that js is NOT installed?
- foob 4y agoJokes aside, this is a actually a pretty common scenario for some people, and I wrote a tool called Exodus to solve it [1]. Exodus makes it trivial to relocate Linux binaries like jq from your local machine [1]. You can simply run 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. [1] - https://github.com/intoli/exodus https://github.com/intoli/exodus
- efrecon 4y agoOoh. Thank you for Exodus! It is fantastic!
- oblio 4y agoThis is up there with the scariest piece of software in existence: https://github.com/xoreaxeaxeax/movfuscator https://github.com/xoreaxeaxeax/movfuscator Presentation of idea: https://m.youtube.com/watch?v=R7EEoWg6Ekk https://m.youtube.com/watch?v=R7EEoWg6Ekk
- computerfriend 4y agoBased on mov is Turing-complete by Stephen Dolan, also the author of jq. Small world.
- stingraycharles 4y agoIs this just a coincidence or was the grandparent aware of this connection?
- WastingMyTime89 4y agoBootstrapping in itself is already a somewhat magical concept even when done in a serious way. I remember the first time I wrote a compiler quite distinctly. There is something special about building something that can build itself. I think it embodies the potential of programming in an absolutely unique way.
- mabbo 4y ago... Can I use it to run jqjq?
- wwader 4y agoYes you can! but it's very slow $ ./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 :)
- lopatin 4y agoAt first I asked "why??" and then I remembered what site we're on. I need to start having fun with tech again.
- deafpolygon 4y agoSCP doesn't work?
- didip 4y agoI have been using gojq, so all I have to do is scp the gojq binary.
- rodorgas 4y agoHow does this language implementations in the language itself works? Isn’t it trivial to implement any feature, given it’s already implemented? They use lower level features to implement higher level ones?
- NoThisIsMe 4y agoSure, you can implement the primitives by just passing through to the host runtime if you want, but you still have to parse the source and walk the AST first.
- thriftwy 4y agoI'm not sure why jq has its own language which is not js based. At least xmlstarlet has xslt for language.
- wwader 4y agoHi author of jqjq here. I don't know why Stephen Dolan designed the jq language the way he did. But for me the most attractive things about jq is the terse and pipe-friendly syntax. This allows you to write queries in shells and REPLs without the need of multiple lines, and it's easy to compose add addition pipes. And by using generators/backtracking you can do complicated traversals over tree and list without much syntax. 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 https://github.com/wader/fq where i've tried to expand on it.
- krick 4y agoHave jq always been a fully-capable turing-complete language? Or did it become this monstrosity step by step, somewhat naturally? I wasn't even aware until today that it's… uh… a programming language.
- wwader 4y agoI think it has been turing complete for a long while. Here is the first prototype in haskell before it was convert to C https://github.com/stedolan/jq/commit/eca89acee00faf6e9ef55d84780e6eeddf225e5c https://github.com/stedolan/jq/commit/eca89acee00faf6e9ef55d..., it's very basic but i would guess it has enough things to be turing complete.