//go:build !goexperiment.jsonv2

package util

import (
	
	
	
	
	
)

type JSON struct{ Value any }

func ( JSON) ( any) error {
	var  []byte

	switch v := .(type) {
	case []byte:
		 = 
	case string:
		 = unsafe.Slice(unsafe.StringData(), len())
	case int64:
		 = strconv.AppendInt(nil, , 10)
	case float64:
		 = AppendNumber(nil, )
	case time.Time:
		 = append(, '"')
		 = .AppendFormat(, time.RFC3339Nano)
		 = append(, '"')
	case nil:
		 = []byte("null")
	default:
		panic(AssertErr())
	}

	return json.Unmarshal(, .Value)
}

func ( []byte,  float64) []byte {
	switch {
	case math.IsNaN():
		 = append(, "null"...)
	case math.IsInf(, 1):
		 = append(, "9.0e999"...)
	case math.IsInf(, -1):
		 = append(, "-9.0e999"...)
	default:
		return strconv.AppendFloat(, , 'g', -1, 64)
	}
	return 
}