When marshalling if the variable reference is nil then json lib encodes it as nil. But for an empty slice preferred would be to have [].

package main

import (
	"encoding/json"
	"fmt"
)

func main() {
	var ids []int
	m := make(map[string]interface{})
	m["ids"] = ids
	b, err := json.Marshal(m)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s", string(b))
}

this would print {"ids":null}, the trick is to initialize ids with

ids := []int{}
  • or -
ids := make([]int, 0)