Skip to content

Commit 44ef3b1

Browse files
committed
Adds a JSON marshalling handler for loader types:
- When martialling, omit the "Builder:" layer of json and just marshal the loaded type directly.
1 parent 98df6af commit 44ef3b1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

loader/loader.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ func (b *Loader[T]) UnmarshalJSON(raw []byte) error {
112112
return json.Unmarshal(raw, b.Builder)
113113
}
114114

115+
func (l Loader[t]) MarshalJSON() ([]byte, error) {
116+
return json.Marshal(l.Builder)
117+
}
118+
115119
func (l Loader[T]) Configure() (T, error) {
116120
var t T
117121
if l.Builder == nil {

0 commit comments

Comments
 (0)