Description
Hey there! 👋🏻
I maintain a JSON Logic implementation in JavaScript called json-logic-engine
.
Fun bit of info before I go into my spiel:
Our implementations of JSON Logic are being used by the CNCF Project OpenFeature,
- https://www.cncf.io/projects/openfeature/
- https://github.com/open-feature/python-sdk-contrib
(To be clear, I'm not affiliated with them other than providing a module 😉)
Your implementation of JSON Logic for Python is very straightforward and has a solid compatibility baseline; it's great!
I wanted to reach out and inquire:
- Is this project still something you're interested in maintaining?
- Would you be interested in working with a community of other JSON Logic maintainers to help develop a more rigorous specification, so we can resolve compatibility issues between implementations?
To be clear... this would be a community effort -- I've been trying to get a hold of Jeremy for a few years now, but I haven't had much success chasing him down 😅 . If he takes notice, I'd love to have him involved.
My goal though is to get a dialog going between different maintainers and build a spec + compat table so JSON Logic can be more beneficial to folks.
There are some quirks with different implementations, some ambiguities in the "spec" we have now, and some impossible behaviors that I think would be helpful for the community to address.
Examples of issues I think need discussed & spec'd:
- Data: How do you access
{ '': 1 }
? - Data: How do you access
{ 'hello.world': 1 }
- Truthiness: straightforward, but a compat table might be helpful
- How do you handle
{ "!": [0] }
vs{ "!": 0 }
-- this one is more straightforward; but a common compat issue. - How do you handle
{ "!": { "var": "data" } }
where data resolves to[0]
, is it treated like[[0]]
or[0]
? - How do you access context in iterators?
{filter: [{var: 'arr'}, {'===': [{var: 'item'}, {var: '../../choice'}]}]}
; explanation: In most implementations, you're unable to access above context in your iterator, so you can't use data to add numbers together, or filter things out. .length
, shouldvar
in JSON Logic have a dedicated handle to allow a user to fetch.length
if the property does not exist on the object naturally? Your implementation handles it withlen()
, but most other implementations do not support.length
. This makes logic incompatible in between interpreters; so should.length
be treated as a special path, or be given a reserved operator 😉
My hope is to get folks discussing backwards compatible approaches, and help provide resources to projects to help iron out implementation differences.
So:
- Would you be interested in participating?
- If not interested in the spec, would you be interested in receiving PRs based on community input?
Appreciated!