Skip to content
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

Usage example is broken #29

Open
4c0n opened this issue Sep 18, 2024 · 6 comments
Open

Usage example is broken #29

4c0n opened this issue Sep 18, 2024 · 6 comments
Assignees

Comments

@4c0n
Copy link

4c0n commented Sep 18, 2024

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

@4c0n 4c0n changed the title Usage example (and 0.1.0 evaluation) is broken Usage example is broken Sep 18, 2024
@Viicos
Copy link
Owner

Viicos commented Sep 25, 2024

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

@Viicos Viicos self-assigned this Sep 25, 2024
@Viicos
Copy link
Owner

Viicos commented Sep 26, 2024

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
Copy link
Author

4c0n commented Sep 26, 2024

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
Copy link
Owner

Viicos commented Sep 26, 2024

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
Copy link
Author

4c0n commented Sep 27, 2024

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
Copy link
Owner

Viicos commented Oct 1, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants