-
-
Notifications
You must be signed in to change notification settings - Fork 53
Closed
Description
Hi,
Is there any plan to support pointer to slice for struct use case?
For example:
func TestPointerSlice(t *testing.T) {
type Child struct {
Current *bool
Value *string
}
type Parent struct {
Children *[]Child
}
data := Parent{
Children: &[]Child{
{Current: pointer(true), Value: pointer("a")},
{Current: pointer(false), Value: pointer("b")},
},
}
expr := jp.MustParseString(".children[?(@.current!=false)].value")
results := expr.Get(data)
got := oj.JSON(results)
if `["a"]` != got {
t.Errorf(`Expected ["a"], got %s`, got)
}
}
func pointer[T any](s T) *T {
return &s
}
If the test is run:
example_test.go:177: Expected ["a"], got []
Metadata
Metadata
Assignees
Labels
No labels