Skip to content

Commit 82ee78d

Browse files
authored
Add Nil type check to ValueOf (#13)
1 parent fea6dd8 commit 82ee78d

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

convert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func ValueOf(v any) Value {
9090
return mapAsTable(v)
9191
case []any:
9292
return sliceAsArray(v)
93-
case nil:
93+
case nil, Nil:
9494
return Nil{}
9595
default:
9696
out, err := json.Marshal(v)

convert_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ func TestValueOf(t *testing.T) {
4747
{input: []float32{1, 2, 3}, output: Numbers{1, 2, 3}},
4848
{input: []float64{1, 2, 3}, output: Numbers{1, 2, 3}},
4949
{input: []bool{false, true}, output: Bools{false, true}},
50+
{input: nil, output: Nil{}},
51+
{input: Nil{}, output: Nil{}},
5052
{input: map[string]any{
5153
"A": "foo",
5254
"B": "bar",

0 commit comments

Comments
 (0)