From b0e443ad99a284b9dd243cebed61f1490bf48481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 23 Mar 2024 18:01:41 +0100 Subject: [PATCH] v0.0.420 --- dataext/optional.go | 11 ++++++++--- goextVersion.go | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dataext/optional.go b/dataext/optional.go index b4667f7..ed89bf8 100644 --- a/dataext/optional.go +++ b/dataext/optional.go @@ -3,6 +3,7 @@ package dataext import ( "encoding/json" "errors" + "gogs.mikescher.com/BlackForestBytes/goext/langext" ) type JsonTwoWayMarshal interface { @@ -10,7 +11,11 @@ type JsonTwoWayMarshal interface { json.Unmarshaler } -type JsonOpt[T JsonTwoWayMarshal] struct { +type JsonOptType interface { + JsonTwoWayMarshal | ~string | ~bool | langext.NumberConstraint +} + +type JsonOpt[T JsonOptType] struct { isSet bool value T } @@ -25,7 +30,7 @@ func (m JsonOpt[T]) MarshalJSON() ([]byte, error) { return []byte("null"), nil } - return m.MarshalJSON() + return json.Marshal(m.value) } // UnmarshalJSON sets *m to a copy of data. @@ -34,7 +39,7 @@ func (m *JsonOpt[T]) UnmarshalJSON(data []byte) error { return errors.New("JsonOpt: UnmarshalJSON on nil pointer") } - return m.value.UnmarshalJSON(data) + return json.Unmarshal(data, &m.value) } func (m JsonOpt[T]) IsSet() bool { diff --git a/goextVersion.go b/goextVersion.go index 5df8ad4..8fc3c96 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.419" +const GoextVersion = "0.0.420" -const GoextVersionTimestamp = "2024-03-23T17:49:56+0100" +const GoextVersionTimestamp = "2024-03-23T18:01:41+0100"