diff --git a/crud.go b/crud.go index 7310911007..8d2af7267c 100644 --- a/crud.go +++ b/crud.go @@ -72,6 +72,10 @@ func crud(resource string, example interface{}, repo Repository, r martini.Route r.JSON(500, struct{}{}) return } + // render an empty JSON array (rather than null) if list is nil + if list == nil { + list = []struct{}{} + } r.JSON(200, list) })