Closed nicholasanthonys closed 3 years ago
Did you try the v3?
I set this up and everything works fine here, take a look:
package jsonlogic_test
import (
"bytes"
"fmt"
"strings"
"testing"
"github.com/diegoholiveira/jsonlogic/v3"
)
func TestGetVarArray(t *testing.T) {
rule := strings.NewReader(`{
"and": [
{
"==": [
{ "var" : "tempNumbers.0"},
"123-456"
]
},
{
"==": [
{ "var" : "tempNumbers.1"},
"234-567"
]
}
]
}`)
data := strings.NewReader(`{
"tempNumbers": [
"123-456",
"234-567",
"345-678"
]
}`)
var result bytes.Buffer
jsonlogic.Apply(rule, data, &result)
fmt.Println(result.String())
}
I just tried the v3 and it works. Thank you.
this is the stack trace :
github.com/diegoholiveira/jsonlogic.getVar(0x74af80, 0xc000182d60, 0x75c0e0, 0xc000185620, 0x100000000754da0, 0xffffffffffffffff) /home/nicholas/Desktop/clone/golang-body-parser/src/vendor/github.com/diegoholiveira/jsonlogic/vars.go:91 +0x725 github.com/diegoholiveira/jsonlogic.operation(0xc000025f36, 0x3, 0x74af80, 0xc000182d60, 0x75c0e0, 0xc000185620, 0x400, 0x7f0e4ca68f00) /home/nicholas/Desktop/clone/golang-body-parser/src/vendor/github.com/diegoholiveira/jsonlogic/jsonlogic.go:540 +0x1105 github.com/diegoholiveira/jsonlogic.apply(0x75c0e0, 0xc000185590, 0x75c0e0, 0xc000185620, 0x194, 0x4007f0e73595768) /home/nicholas/Desktop/clone/golang-body-parser/src/vendor/github.com/diegoholiveira/jsonlogic/jsonlogic.go:708 +0x1dc github.com/diegoholiveira/jsonlogic.parseValues(0x7465e0, 0xc00019ac20, 0x75c0e0, 0xc000185620, 0x0, 0x0) /home/nicholas/Desktop/clone/golang-body-parser/src/vendor/github.com/diegoholiveira/jsonlogic/jsonlogic.go:674 +0x2ac github.com/diegoholiveira/jsonlogic.apply(0x75c0e0, 0xc000185560, 0x75c0e0, 0xc000185620, 0xc000053d90, 0x30000000054128a) /home/nicholas/Desktop/clone/golang-body-parser/src/vendor/github.com/diegoholiveira/jsonlogic/jsonlogic.go:708 +0x196 github.com/diegoholiveira/jsonlogic.parseValues(0x7465e0, 0xc00019aca0, 0x75c0e0, 0xc000185620, 0x0, 0xc000132660) /home/nicholas/Desktop/clone/golang-body-parser/src/vendor/github.com/diegoholiveira/jsonlogic/jsonlogic.go:674 +0x2ac github.com/diegoholiveira/jsonlogic.apply(0x75c0e0, 0xc000185530, 0x75c0e0, 0xc000185620, 0x0, 0x8d7308) /home/nicholas/Desktop/clone/golang-body-parser/src/vendor/github.com/diegoholiveira/jsonlogic/jsonlogic.go:708 +0x196 github.com/diegoholiveira/jsonlogic.Apply(0x827320, 0xc00019abc0, 0x827320, 0xc00019abe0, 0x826c20, 0xc000185500, 0x2202e31c0000000f, 0x6071bd75) /home/nicholas/Desktop/clone/golang-body-parser/src/vendor/github.com/diegoholiveira/jsonlogic/jsonlogic.go:736 +0x1ec github.com/nicholasanthonys/Golang-Body-Parser/test.TestGetVarArray(0xc000001b00) /home/nicholas/Desktop/clone/golang-body-parser/src/test/clogic_test.go:169 +0xee testing.tRunner(0xc000001b00, 0x7d5518) /home/nicholas/go1.15.5/src/testing/testing.go:1123 +0xef created by testing.(*T).Run /home/nicholas/go1.15.5/src/testing/testing.go:1168 +0x2b3
Can you help me with this ?