Skip to content

Commit

Permalink
unpack several levels of pointers to strings (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
bronze1man authored Apr 19, 2022
1 parent afb535c commit eab10f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ func (e *hjsonEncoder) str(value reflect.Value, noIndent bool, separator string,
e.WriteString("null")
return nil
}
value = value.Elem()
kind = value.Kind()
return e.str(value.Elem(),noIndent,separator,isRootObject)
}

if value.Type().Implements(marshaler) {
Expand Down
16 changes: 16 additions & 0 deletions encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,19 @@ func TestEncodeMarshal(t *testing.T) {
t.Error("Marshaler interface error")
}
}

func TestEncodeSliceOfPtrOfPtrOfString(t *testing.T) {
s:="1"
s1:=&s
input:=[]**string{&s1}
buf, err := Marshal(input)
if err != nil {
t.Error(err)
return
}
if !reflect.DeepEqual(buf, []byte(`[
"1"
]`)) {
t.Error("Marshaler interface error")
}
}

0 comments on commit eab10f1

Please sign in to comment.