interface{} accepts any type. Go 1.18+ aliases it as any.

// Old
func Marshal(v interface{}) ([]byte, error)
 
// Modern (1.18+)
func Marshal(v any) ([]byte, error)

interface{} vs []interface{}

var x any         = "hello"              // single value of any type
var y []any       = []any{1, "a", true}  // slice where each element can differ

json.Marshal takes any because it needs to handle structs, maps, slices, primitives — all via reflection at runtime.