summaryrefslogtreecommitdiffhomepage
path: root/types
diff options
context:
space:
mode:
Diffstat (limited to 'types')
-rw-r--r--types/views/views.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/types/views/views.go b/types/views/views.go
index 42758966f..fa0e45adb 100644
--- a/types/views/views.go
+++ b/types/views/views.go
@@ -13,6 +13,9 @@ import (
"maps"
"slices"
+ jsonexp "github.com/go-json-experiment/json"
+ jsontext "github.com/go-json-experiment/json/jsontext"
+
"go4.org/mem"
)
@@ -225,6 +228,13 @@ func (v Slice[T]) MarshalJSON() ([]byte, error) {
return json.Marshal(v.ж)
}
+var _ jsonexp.MarshalerV2 = Slice[string]{nil}
+
+// MarshalJSON implements github.com/go-json-experiment/json.MarshalerV2.
+func (v Slice[T]) MarshalJSONV2(e *jsontext.Encoder, opts jsonexp.Options) error {
+ return jsonexp.MarshalEncode(e, v.ж, opts)
+}
+
// UnmarshalJSON implements json.Unmarshaler.
func (v *Slice[T]) UnmarshalJSON(b []byte) error {
return unmarshalSliceFromJSON(b, &v.ж)