You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: querystring.go
    path of file: ./repos/wundergraph/pkg/querystring
    
    the code of the file until where you have to start completion: package querystring

import (
	"encoding/json"
	"errors"
	"net/url"
	"regexp"
	"strings"

	"golang.org/x/exp/slices"
)

var (
	// ErrInvalidParam is returned when invalid data is provided to the ToJSON or Unmarshal function.
	// Specifically, this will be returned when there is no equals sign present in the URL query parameter.
	ErrInvalidParam error = errors.New("qson: invalid url query param provided")

	bracketSplitter *regexp.Regexp
)

func init()
    
func ToJSON(query string, allowList []string) ([]byte, error) {

	if query == "" {
		return []byte("{}"), nil
	}

	if strings.Contains(query, "wg_variables") {
		values, err := url.ParseQuery(query)
		if err != nil {
			return nil, err
		}
		if values.Has("wg_variables") {
			return []byte(values.Get("wg_variables")), nil
		}
	}

	var (
		builder interface{} = make(map[string]any)
	)
	params := strings.Split(query, "&")
	for _, part := range params {
		if strings.HasPrefix(part, "wg_") {
			continue
		}
		tempMap, err := queryToMap(part, allowList)
		if err != nil {
			return nil, err
		}
		if tempMap == nil {
			continue
		}
		builder = merge(builder, tempMap)
	}
	return json.Marshal(builder)
}