File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ type Marshaller interface {
52
52
// In all other cases we can't derive the type in a meaningful way and is therefore an `interface{}`.
53
53
func Marshal (options * Options , data interface {}) (interface {}, error ) {
54
54
v := reflect .ValueOf (data )
55
+ if ! v .IsValid () {
56
+ return data , nil
57
+ }
55
58
t := v .Type ()
56
59
57
60
// Initialise nestedGroupsMap,
Original file line number Diff line number Diff line change @@ -663,3 +663,15 @@ func TestMarshal_AliaString(t *testing.T) {
663
663
_ , err := Marshal (& Options {}, & v )
664
664
assert .NoError (t , err )
665
665
}
666
+
667
+ type EmptyInterfaceStruct struct {
668
+ Data interface {} `json:"data"`
669
+ }
670
+
671
+ func TestMarshal_EmptyInterface (t * testing.T ) {
672
+ v := EmptyInterfaceStruct {}
673
+ o := & Options {}
674
+
675
+ _ , err := Marshal (o , v )
676
+ assert .NoError (t , err )
677
+ }
You can’t perform that action at this time.
0 commit comments