Array returns an empty JSON array if v is a nil slice, so that it renders as "[]" rather than "null". Otherwise, it returns v.
(v interface{})
| 50 | // so that it renders as "[]" rather than "null". |
| 51 | // Otherwise, it returns v. |
| 52 | func Array(v interface{}) interface{} { |
| 53 | if rv := reflect.ValueOf(v); rv.Kind() == reflect.Slice && rv.IsNil() { |
| 54 | v = []struct{}{} |
| 55 | } |
| 56 | return v |
| 57 | } |
no outgoing calls
no test coverage detected