qlog: implement a minimal jsontext-like JSON encoder (#5353)

* qlog: use fork of encoding/json/jsontext instead of unmaintained gojay

* implement a minimal jsontext-compatible encoder

* qlogtext: improve fuzz test

* qlog: simplify JSON encoding error handling

* qlog: make use of jsontext.Bool
This commit is contained in:
Marten Seemann
2025-10-06 12:48:40 +08:00
committed by GitHub
parent 7c1ce0efe2
commit e6d5d960e3
14 changed files with 1714 additions and 637 deletions

View File

@@ -6,17 +6,19 @@ import (
"testing"
"time"
"github.com/francoispqt/gojay"
"github.com/quic-go/quic-go/internal/protocol"
"github.com/quic-go/quic-go/internal/qerr"
"github.com/quic-go/quic-go/logging"
"github.com/quic-go/quic-go/qlog/jsontext"
"github.com/stretchr/testify/require"
)
func check(t *testing.T, f logging.Frame, expected map[string]any) {
buf := &bytes.Buffer{}
enc := gojay.NewEncoder(buf)
err := enc.Encode(frame{Frame: f})
enc := jsontext.NewEncoder(buf)
err := (frame{Frame: f}).Encode(enc)
require.NoError(t, err)
data := buf.Bytes()
require.True(t, json.Valid(data))