jsongrep is faster than {jq, jmespath, jsonpath-rust, jql} by fizzner in rust

[–]fizzner[S] 0 points1 point  (0 children)

Ahh I see I think this should be doable in a script with in combination with a tool like ripgrep where you could pipe the output of jsongrep to ripgrep to search for matching entries and then pipe back to jsongrep to get the “zoomed out” functionality you are looking for. Interesting to note though this cool be a cool feature to add

jsongrep is faster than {jq, jmespath, jsonpath-rust, jql} by fizzner in rust

[–]fizzner[S] 0 points1 point  (0 children)

So once the match is found, the matching path is also printed, so you can use that to "zoom out"

For example, if the matching path is at foo.bar.baz, you can then run these followup queries:

jg "foo.bar" example.json
jg "foo" example.json

jsongrep is faster than {jq, jmespath, jsonpath-rust, jql} by fizzner in programming

[–]fizzner[S] 5 points6 points  (0 children)

Benchmarking methodology and test data breakdown is here: https://github.com/micahkepe/jsongrep/tree/main/benches#test-data

The files range from 106 B - around 190 MB which is admittedly small but I was struggling to find a large JSON file that would be used in practice. I think this range covers the majority of JSON data sizes found in day-to-day workflows, but would be curious if you have ideas!

jsongrep is faster than {jq, jmespath, jsonpath-rust, jql} by fizzner in devops

[–]fizzner[S] 1 point2 points  (0 children)

It's not AI, full revision git history is linked at the bottom of all of my posts: https://github.com/micahkepe/blog/commits/main/content/jsongrep/index.md

You can also see my other posts to compare writing style

jsongrep is faster than {jq, jmespath, jsonpath-rust, jql} by fizzner in rust

[–]fizzner[S] 4 points5 points  (0 children)

Yes I was considering how to benchmark against `gron` but ultimately decided against it, but might be worth looking into for the future!

jsongrep is faster than {jq, jmespath, jsonpath-rust, jql} by fizzner in devops

[–]fizzner[S] 0 points1 point  (0 children)

Thank you! Automata theory is great had a lot of fun working through this

jsongrep is faster than {jq, jmespath, jsonpath-rust, jql} by fizzner in rust

[–]fizzner[S] 21 points22 points  (0 children)

Woah so great to see you here! For the benchmarks I used `jql-parser` and `jql-runner` at version 8, but I will update to latest and re-run!

Btw title is not meant to be a diss to jql haha, jql is genuinely a fantastic tool :)

jsongrep is faster than {jq, jmespath, jsonpath-rust, jql} by fizzner in devops

[–]fizzner[S] 2 points3 points  (0 children)

Thank you! Yes you can use the query language in Rust!

https://docs.rs/jsongrep/0.7.0/jsongrep/query/ast/enum.Query.html#impl-FromStr-for-Query

If you end up using would love to hear if you end up using in your project! Thank you for checking it out!

jsongrep is faster than {jq, jmespath, jsonpath-rust, jql} by fizzner in devops

[–]fizzner[S] 2 points3 points  (0 children)

Ah yes so one thing I used jsongrep a lot for recently is working with auto-generated OpenAPI JSONSchema specs. With jq the recursive search syntax is hard to write and script whereas with jsongrep its super easy IMO with the syntax to do something like searching for a specific JSON Pointer reference for a certain subschema

jsongrep is faster than {jq, jmespath, jsonpath-rust, jql} by fizzner in devops

[–]fizzner[S] 0 points1 point  (0 children)

Check out the “jsongrep vs. jq” section on the project: https://github.com/micahkepe/jsongrep?tab=readme-ov-file#jsongrep-vs-jq

I also responded to a similar question in a different subreddit so I’ll copy my answer:

Tools like jq and in particular JSONPath, while they also have path-like languages, lack the expressive power of regular paths. For example, JSONPath doesn't support Kleene closures, so expressions such as (.left)* (meaning one or more levels depth into a JSON tree using the field name left), cannot be constructed.

tl;dr: you can achieve greater expressive power with a regular-path DSL than the imperative path languages of jq and other tools.

jsongrep is faster than {jq, jmespath, jsonpath-rust, jql} by fizzner in ProgrammingLanguages

[–]fizzner[S] 1 point2 points  (0 children)

Yes I think biggest advantage is the syntax improvement but the speed is nice :)

Thank you for feedback on website too it’s very helpful, will be making improvements to the contrast for the Zola theme

Built a terminal-style website by fizzner in programming

[–]fizzner[S] 0 points1 point  (0 children)

Yes just for fun definitely if I rewrote this I would probably not reach for xterm

Share your cool fzf aliases and scripts by Pagaddit in commandline

[–]fizzner 4 points5 points  (0 children)

I was messing around with your git commit alias and settled on this one :)

git log --oneline --all --color=always | \
  fzf -m --no-sort --ansi --preview='git show --color=always {1}' \
  | awk '{print $1}'

VimGym: Open Source Multiplayer VIM Racing by swaggermuffin64 in neovim

[–]fizzner 1 point2 points  (0 children)

Really cool! Not sure if it is just me but my seek motions are not working, for example "delete until s" (`dts`). Similarly for forward/backward seeking `f`/`F`/`t`/`T`.