Open cj-f opened 1 month ago
@joaoandre do you remember how we solve this issue?
Actually upon further testing it appears that when using some
and the golang jsonlogic pkg, that you can access absolute variable paths, but when using all
it does not seem to resolve absolute vars. When testing on https://jsonlogic.com/play.html
I notice both all
and some
do not resolve absolute variables.
So there may be a difference in the golang package with some
. I'm currently testing on github.com/diegoholiveira/jsonlogic/v3 v3.5.3
Although I will say I like the behavior of some
in go even if it may be a bug, because I want absolute variables to resolve haha, but I would need it to also work with all
Is the reduce
operation also not support in the golang pkg of jsonlogic. I was trying to think of another option if I could get all
to work, and figured I could reduce
and then cat
to build a single string to perform and ==
check against, but that works on the website, doesn't work using the pkg. Although I just noticed I don't see reduce
in the operations.go file
Hi, @cj-f the error you see in json logic is interface conversion: interface {} is map[string]interface {}, not []interface {}
Hey, not sure if this is best place to post this question, as I don't think it is a problem with the golang jsonlogic as I am noticing the same behavior in go as I do in the play.html page on jsonlogic, but I'm trying to figure out how I can compare array values against data outside of the array
I know that
var
inside of an array is relative, so{ "var": "id" }
appears to work, but is there any way I could check that against data outside of the array like thesubject.id
. Ifvar
inside an array is only relative, is the only solution to add a custom operator likeabsolute_var
, if yes, if there any online examples where I could understand how to write an operator like that in golangRule:
{"some": [{ "var": "attributes.parents" }, {"==": [{ "var": "id" }, { "var": "subject.id" }]}]}
Data:
{ "subject": { "id": "hugh", }, "attributes": { "parents": [ { "id": "ryan" }, { "id": "hugh" }, ] } }