diff --git a/dataconv/marshal.go b/dataconv/marshal.go index 3fe44e4..2c0821d 100644 --- a/dataconv/marshal.go +++ b/dataconv/marshal.go @@ -3,6 +3,7 @@ package dataconv // Based on https://github.com/qri-io/starlib/tree/master/util with some modifications and additions import ( + "encoding/json" "errors" "fmt" "time" @@ -23,6 +24,8 @@ func Marshal(data interface{}) (v starlark.Value, err error) { v = starlark.Bool(x) case string: v = starlark.String(x) + case json.Number: + v = starlark.String(x) case int: v = starlark.MakeInt(x) case int8: diff --git a/dataconv/marshal_test.go b/dataconv/marshal_test.go index 28c416a..2ba7d0f 100644 --- a/dataconv/marshal_test.go +++ b/dataconv/marshal_test.go @@ -68,6 +68,7 @@ func TestMarshal(t *testing.T) { {nil, starlark.None, ""}, {true, starlark.True, ""}, {"foo", starlark.String("foo"), ""}, + {json.Number("42"), starlark.String("42"), ""}, {42, starlark.MakeInt(42), ""}, {int8(42), starlark.MakeInt(42), ""}, {int16(42), starlark.MakeInt(42), ""},