-
Notifications
You must be signed in to change notification settings - Fork 7
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
Sweet project! #6
Comments
Since nimma is the closest competitor that I have found to object-scan, I've spend quite some time looking at differences. I've added a big section in the readme, but am going to add lots of notes here in the hopes that it will help you make your library better! Here is the relevant PR. Note that I have not looked at the "generating code" feature as that is far beyond the specs of object-scan. Here we go, in no particular order:
The readme of object-scan is extensive. So I'm sure you could get a lot of inspiration just reading through that. On the flip side, the biggest problem I've seen with object-scan is that it doesn't align with the jsonpath syntax. It is close, but doesn't fully support it. In particular conditionals are not supported. Something I have to put onto the roadmap. That and typescript support. This was a fun exploration! Thank you and I hope you find this somewhat useful =) |
That library was primarily meant to be a drop-in replacement for jsonpath-plus to use in stoplight/spectral, hence some similarities, i.e. in callbacks. Frankly speaking, I'm not sure really sure whether Nimma means to be a competitor to object-scan or jmespath. The syntax of expressions they accept is quite different after all. It's certainly however more of a direct competitor to jsonpath or jsonpath-plus.
I don't build a search tree. I was thinking about that, but it's rather tricky to do given a JSONPath expression may contain any arbitary JS code, so one would need to analyze that too. Your tool doesn't support it, so it is way easier to determine which properties are to be matched. It's not really a search tree, however.
Parsing is quite expensive. I could write my own parser, but I stuck with peg, so there's some room for improvement here for sure. Obviously, I generate the JS code there that then needs to be evaluated again at runtime, but there isn't much one can notably improve here.
No point tbh - JSONPath expressions are meant to deal with JSON input, so that's not really worth putting any effort into.
Yeah, I know the path is mutated, and that's mostly to avoid the perf cost of new array allocation.
Agreed, I don't like it either - it's mostly so I could integrate it easily in Spectral without many code changes 😉.
Yep, again mostly due to the needs of stoplight/spectral.
Yup, readme is certainly something I could improve here. :D
Thanks a lot for the feedback! |
Was just browsing for competitors to object-scan and this popped up!
Awesome project, I have to look into it in more detail and will definitely add it to the functionality comparison and performance benchmarking suite of object-scan! I'm really looking forward to testing how it compares performance wise!
I have to look at the source code as well. I'm assuming you have a precompilation phase where you build a search tree? Or how does this work internally? What are the next things on the roadmap for this project?
PS: If it wasn't clear from my comment, I'm the author of object-scan
Edit: Read up on how this works internally and can't wait to try it out! It's actually quite different and a cool way of handling the multi path traversal case. However does it require always a full traversal of the entire input?
The text was updated successfully, but these errors were encountered: