Compare commits

...

3 Commits

Author SHA1 Message Date
8bf3a337cf v0.0.422
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m29s
2024-03-23 20:29:46 +01:00
16146494dc v0.0.421
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 32s
2024-03-23 20:28:51 +01:00
b0e443ad99 v0.0.420
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Failing after 36s
2024-03-23 18:01:41 +01:00
2 changed files with 5 additions and 14 deletions

View File

@@ -5,12 +5,7 @@ import (
"errors"
)
type JsonTwoWayMarshal interface {
json.Marshaler
json.Unmarshaler
}
type JsonOpt[T JsonTwoWayMarshal] struct {
type JsonOpt[T any] struct {
isSet bool
value T
}
@@ -21,11 +16,7 @@ func (m JsonOpt[T]) MarshalJSON() ([]byte, error) {
return []byte("null"), nil // actually this would be undefined - but undefined is not valid JSON
}
if m.value == nil {
return []byte("null"), nil
}
return m.MarshalJSON()
return json.Marshal(m.value)
}
// UnmarshalJSON sets *m to a copy of data.
@@ -34,7 +25,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 {

View File

@@ -1,5 +1,5 @@
package goext
const GoextVersion = "0.0.419"
const GoextVersion = "0.0.422"
const GoextVersionTimestamp = "2024-03-23T17:49:56+0100"
const GoextVersionTimestamp = "2024-03-23T20:29:46+0100"