perf(json): replace encoding/json with bytedance/sonic

Migrate all JSON marshaling and unmarshaling operations to use
github.com/bytedance/sonic for improved performance. This affects
adapters, middleware, proxy handlers, and the sync store.
This commit is contained in:
zenfun
2025-12-10 23:21:51 +08:00
parent 770a9fef2b
commit 5826db3954
5 changed files with 13 additions and 12 deletions

View File

@@ -4,13 +4,13 @@ package integration
import (
"bytes"
"encoding/json"
"io"
"net/http"
"os"
"testing"
"time"
"github.com/bytedance/sonic"
"github.com/stretchr/testify/require"
)
@@ -54,7 +54,7 @@ func TestEndToEnd(t *testing.T) {
}
func postJSONWithAuth[T any](t *testing.T, client *http.Client, url string, body interface{}, out T, token string) T {
b, err := json.Marshal(body)
b, err := sonic.Marshal(body)
require.NoError(t, err)
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(b))
@@ -76,7 +76,7 @@ func postJSONWithAuth[T any](t *testing.T, client *http.Client, url string, body
if out != nil {
data, _ := io.ReadAll(resp.Body)
if len(data) > 0 {
require.NoError(t, json.Unmarshal(data, out))
require.NoError(t, sonic.Unmarshal(data, out))
}
}
return out