mirror of
https://github.com/aykhans/sarin.git
synced 2026-10-14 21:58:51 +00:00
🐛 Return empty brackets instead of null when slice length is 0
This commit is contained in:
1 parent
8a3574cd48
commit
40f8a1cc37
1 file changed
+3
@@ -17,6 +17,9 @@ func (t TruncatedMarshaller) MarshalJSON() ([]byte, error) {
|
||||
if val.Kind() != reflect.Slice && val.Kind() != reflect.Array {
|
||||
return json.Marshal(t.Value)
|
||||
}
|
||||
if val.Len() == 0 {
|
||||
return []byte("[]"), nil
|
||||
}
|
||||
|
||||
length := val.Len()
|
||||
if length <= t.MaxItems {
|
||||
|
||||
Reference in new issue
Block a user