-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using JAQ with a custom type #173
Comments
The gojq fork used by fq adds a |
Hi @tusharmath! I have already thought about making the jaq value type more flexible, in order to support use cases like yours. I suppose that an approach like @wader's could work, and this might even allow jaq to be made flexible enough to support more input formats, like We could, for example, make a Can you show us what your value type looks like? That would help fleshing out whether the approach I outlined above would be applicable here. |
(Thanks, @wader, by the way for explaining how you do it in |
@tusharmath, I created a trait in jaq called |
Thanks for getting back @01mf02 ! Yes we can implement ValT. I would recommend making the trait public but marking it as unstable and hide it using the unstable feature flag. Folks like us could try it out and give you feedback without expecting a major version increase on breaking changes. // This trait will be public if 'unstable' feature is enabled, otherwise it's crate-private
#[cfg_attr(feature = "unstable", pub)]
trait ValT {
}
// Implement the trait conditionally
#[cfg(feature = "unstable")]
impl ValT for MyStruct {
} |
@ssddOnTop hey! just to expand a bit on on my comment above. To implement some fq features (query then hexdump, binary concat/slice etc) it's important that an instance of something that implements the |
Aha i see 👍 |
@tusharmath, I'm happy to hear that you can implement |
@wader, the "survival" of jq values is preserved by the introduction of the |
Great! that seem to be more than what my fork does atm. I think that will enable some interesting possibilities. The thing that was trickest and broke to most things when adding a |
Just to clarify, the interface I defined for values is quite minimal right now and only supports operations for which there exists dedicated syntax in jq (such as |
Thanks for an amazing library in Rust! I plan to add support for JAQ in tailcallhq/tailcall#1321 However there are a few concerns:
I have a "json-like" structure (not serde_json) that I'd like to integrate with JAQ. Is there a way to do it? What components can I reuse vs re-implement?
The text was updated successfully, but these errors were encountered: