Skip to content

Commit

Permalink
Return JSON marshallable empty response. (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
notbdu committed Feb 11, 2019
1 parent e0d1341 commit 67393e3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion query/grouped_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const (
defaultTrimTriggerSizeMultiplier = 4
)

var (
emptyJSONResponse = []byte("{}")
)

// GroupedResults is a collection of result groups.
type GroupedResults struct {
// GroupBy contains a list of field paths to group results by.
Expand Down Expand Up @@ -175,7 +179,7 @@ func (r *GroupedResults) TrimIfNeeded() {
// MarshalJSON marshals the grouped results as a JSON object.
func (r *GroupedResults) MarshalJSON() ([]byte, error) {
if r.IsEmpty() {
return nil, nil
return emptyJSONResponse, nil
}
var (
limit = r.Limit
Expand Down

0 comments on commit 67393e3

Please sign in to comment.