Viicos / jsonlogic

An extensible and sane implementation of JsonLogic
https://jsonlogic.readthedocs.io/
MIT License
3 stars 0 forks source link

Usage example is broken #29

Open 4c0n opened 1 month ago

4c0n commented 1 month ago

Hi first of all thanks for the effort of putting this library together!

Since version 0.1.0 the usage example seems to be broken. The output is now:

{'>': [JSONLogicExpression(expression={'var': ['my_int']}), 2]}

while according to the docs the output should be:

{'>': [JSONLogicExpression(expression={'var': [JSONLogicExpression(expression='my_int')]}), JSONLogicExpression(expression=2)]}

which it is in version 0.0.1

Viicos commented 1 month ago

Thanks for the report, I'll take a look shortly.

Viicos commented 1 month ago

By the way, I just came across https://github.com/Amsterdam/pydantic-jsonlogic. I also had the idea to first try doing the implementation with Pydantic.

https://github.com/Viicos/jsonlogic was kind of a side project when I was working on https://github.com/open-formulieren/open-forms/, which you may know already. We made use of JSONLogic as well but with an old Python implementation.

cc @sergei-maertens @CharString, you might be interested.

4c0n commented 1 month ago

Cool! Yeah that makes sense, I think my colleague has been in touch with some people from the open formulieren project. Unfortunately we weren't able to use this lib for our project because it does the variable lookup differently from the javascript implementation. Which is a shame really, because I feel that the quality is much better than the broken python lib on jsonlogic.com. So currently we're using the Maykin fork.

Viicos commented 1 month ago

Unfortunately we weren't able to use this lib

Are you talking about this one? Because if so, note that even if the default variable lookup uses the same format as RFC 6901, you can still configure which lookup format to use and in particular I provide DotReferenceParser, aligned with the original JS implementation.

4c0n commented 1 month ago

Ah right, I totally missed that. That's actually quite useful, might have to switch back to this library eventually. I also like the type aliases, they could be very useful in our pydantic lib.

Viicos commented 1 month ago

I see you edited your original post regarding a potential type error. Was it an issue on your end?