// Package wire is JSON as the TypeScript runtime writes it: no HTML escaping of <, > and &. package wire import ( "bytes" "encoding/json" ) // Marshal encodes v the way JSON.stringify does, without a trailing newline. func Marshal(v any) ([]byte, error) { var b bytes.Buffer enc := json.NewEncoder(&b) enc.SetEscapeHTML(false) if err := enc.Encode(v); err != nil { return nil, err } return bytes.TrimRight(b.Bytes(), "\n"), nil }