-
Notifications
You must be signed in to change notification settings - Fork 141
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
Better support for others who want to create implementations #93
Comments
OK, well the good news is that there is a common test suite. The unit tests in this repo are downloading http://jsonlogic.com/tests.json and treating the whole thing as an array, and each row of that array as That gives me a common 275 item test suite across the two implementations I maintain, PHP and JavaScript. But you're right, most operators are implemented to just delegate the decision to the language in the fewest lines of code. The entire JavaScript implementation of
The one place I found I just couldn't live with the ambiguity was truthiness, which is why JsonLogic has its own truth table: https://jsonlogic.com/truthy.html It's certainly possible that you could define the same thing for "what is JsonLogic's opinion of I think if you wanted to make a .NET version that passed the common tests and then went absolutely berserk on type inconsistencies (e.g., if you call I also think I screwed up the spec when I allowed single-argument operators to skip the [] around args, e.g. |
Thanks for the explanation and the link to the tests. I might pick it up again. I suppose the |
More on the casting issue, cases like |
I created a port to Rust a while ago (jsonlogic_rs) and faced the same problems. In the end I actually reimplemented the way JavaScript handles types and their coercion and created tests for all examples on jsonlogic.com and all other funny edge cases I could imagine, so stuff like Even if tedious, it can be done by "just" following the language spec and it was actually a nice insight for me. My personal "highlight" is the specification of abstract equality ( |
Okay. I have all the tests passing except two of the #1
(a) This returns an empty array, so there's nothing to apply the rule to. Do we require that #2
Basically the same test, except we have Note that if |
Alright... I've published my first version. Passes the entire test suite (with the assumptions above). |
How does one go about getting added to the site as an implementation? Would a PR here suffice? |
This isn't an issue for this library so much as for JsonLogic in general.
I started on a .Net implementation of JsonLogic, but found there were too many inconsistencies in the online implementation. I've
complained aboutdescribed some of these inconsistencies in my issue to add this support.Ideally, I'd like to see:
The text was updated successfully, but these errors were encountered: