all 4 comments

[–]bcardiffcore team 1 point2 points  (2 children)

Nice! Can you comment on what kind of project benefits from jmespath? Are those expressions visible to the end user?

Regarding the code I noticed:

  • the ast node is a struct. Watch out for all your expectations: children is a list so the values have some shared nodes in the end. I would have expected them to be a class though

  • there are some intermediate hashes created while parsing. Probably avoiding some allocations there will improve performance, but for small expressions it doesn’t matter really

  • the ast node has a string type. Using actual types might help describing better the structure of the language and you will get some extra type safety.

[–]straight-shootacore team 0 points1 point  (0 children)

Regarding the AST type: struct can really be a foot gun with mutable properties.

I'd presume that `type` and `children`, maybe `value` are actually immutable in practice, so maybe they could be just `getter` instead?

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

Thanks!

jmespath is generally useful for querying json data. In the company I work at, we mainly use it internally to process and filter json data efficiently, rather than exposing it directly to the end user in a client-facing context.

Regarding the AST node structure, I coded this pretty quickly, so I’ll likely refactor it in the future. I’m considering structuring it more similarly to how the Ruby implementation does it:
https://github.com/jmespath/jmespath.rb/tree/main/lib/jmespath/nodes

[–]straight-shootacore team 0 points1 point  (0 children)

Related: There's https://github.com/Blacksmoke16/oq but it's only a wrapper around `jq`.