diff --git a/test/main.go b/test/main.go index 58b8986..28edad6 100644 --- a/test/main.go +++ b/test/main.go @@ -126,14 +126,15 @@ func main() { // ExampleOmit() //} - fmt.Println(filter.Omit("1", User{})) - fmt.Println(filter.Omit("1", User{})) - fmt.Println(filter.Omit("1", User{})) - fmt.Println(filter.Omit("1", User{})) - fmt.Println(filter.Omit("1", User{})) - fmt.Println(filter.Omit("1", User{})) - fmt.Println(filter.Omit("1", User{})) - fmt.Println(filter.Omit("1", User{})) + //fmt.Println(filter.Omit("1", User{})) + //fmt.Println(filter.Omit("1", User{})) + //fmt.Println(filter.Omit("1", User{})) + //fmt.Println(filter.Omit("1", User{})) + //fmt.Println(filter.Omit("1", User{})) + //fmt.Println(filter.Omit("1", User{})) + //fmt.Println(filter.Omit("1", User{})) + //fmt.Println(filter.Omit("1", User{})) + TestNilValue() } diff --git a/test/nil_value.go b/test/nil_value.go new file mode 100644 index 0000000..6f62dd9 --- /dev/null +++ b/test/nil_value.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "github.com/liu-cn/json-filter/filter" +) + +func TestNilValue() { + var a *T + var c *T + var el = map[string]interface{}{ + "a": a, // a: nil ptr + "b": 1, + "c": map[string]interface{}{ + "bb": nil, + "dd": c, // dd: nil ptr + }, + } + + fmt.Println(filter.Select("test", el)) + //{"a":null,"b":1,"c":{"bb":null,"dd":null}} + +} + +type T struct { + A string `json:"a,select(test)"` +}