Skip to content

Commit acb2b46

Browse files
committed
Drop json-iterator dependency (go-gitea#35544)
# Conflicts: # go.mod
1 parent 2fc8c67 commit acb2b46

File tree

4 files changed

+8
-71
lines changed

4 files changed

+8
-71
lines changed

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ require (
6060
github.com/go-ldap/ldap/v3 v3.4.11
6161
github.com/go-redsync/redsync/v4 v4.13.0
6262
github.com/go-sql-driver/mysql v1.9.3
63-
github.com/go-webauthn/webauthn v0.14.0
63+
<<<<<<< HEAD
64+
github.com/go-webauthn/webauthn v0.13.4
6465
github.com/goccy/go-json v0.10.5
6566
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f
6667
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85
@@ -199,7 +200,8 @@ require (
199200
github.com/go-fed/httpsig v1.1.1-0.20201223112313-55836744818e // indirect
200201
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
201202
github.com/go-ini/ini v1.67.0 // indirect
202-
github.com/go-webauthn/x v0.1.25 // indirect
203+
<<<<<<< HEAD
204+
github.com/go-webauthn/x v0.1.24 // indirect
203205
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
204206
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
205207
github.com/golang-sql/sqlexp v0.1.0 // indirect

modules/json/json.go

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -29,70 +29,7 @@ type Interface interface {
2929
Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error
3030
}
3131

32-
var (
33-
DefaultJSONHandler = getDefaultJSONHandler()
34-
35-
_ Interface = StdJSON{}
36-
_ Interface = JSONiter{}
37-
)
38-
39-
// StdJSON implements Interface via encoding/json
40-
type StdJSON struct{}
41-
42-
// Marshal implements Interface
43-
func (StdJSON) Marshal(v any) ([]byte, error) {
44-
return json.Marshal(v)
45-
}
46-
47-
// Unmarshal implements Interface
48-
func (StdJSON) Unmarshal(data []byte, v any) error {
49-
return json.Unmarshal(data, v)
50-
}
51-
52-
// NewEncoder implements Interface
53-
func (StdJSON) NewEncoder(writer io.Writer) Encoder {
54-
return json.NewEncoder(writer)
55-
}
56-
57-
// NewDecoder implements Interface
58-
func (StdJSON) NewDecoder(reader io.Reader) Decoder {
59-
return json.NewDecoder(reader)
60-
}
61-
62-
// Indent implements Interface
63-
func (StdJSON) Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error {
64-
return json.Indent(dst, src, prefix, indent)
65-
}
66-
67-
// JSONiter implements Interface via jsoniter
68-
type JSONiter struct {
69-
jsoniter.API
70-
}
71-
72-
// Marshal implements Interface
73-
func (j JSONiter) Marshal(v any) ([]byte, error) {
74-
return j.API.Marshal(v)
75-
}
76-
77-
// Unmarshal implements Interface
78-
func (j JSONiter) Unmarshal(data []byte, v any) error {
79-
return j.API.Unmarshal(data, v)
80-
}
81-
82-
// NewEncoder implements Interface
83-
func (j JSONiter) NewEncoder(writer io.Writer) Encoder {
84-
return j.API.NewEncoder(writer)
85-
}
86-
87-
// NewDecoder implements Interface
88-
func (j JSONiter) NewDecoder(reader io.Reader) Decoder {
89-
return j.API.NewDecoder(reader)
90-
}
91-
92-
// Indent implements Interface, since jsoniter don't support Indent, just use encoding/json's
93-
func (j JSONiter) Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error {
94-
return json.Indent(dst, src, prefix, indent)
95-
}
32+
var DefaultJSONHandler = getDefaultJSONHandler()
9633

9734
// Marshal converts object as bytes
9835
func Marshal(v any) ([]byte, error) {

modules/json/jsonlegacy.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ package json
77

88
import (
99
"io"
10-
11-
jsoniter "github.com/json-iterator/go"
1210
)
1311

1412
func getDefaultJSONHandler() Interface {
15-
return JSONiter{jsoniter.ConfigCompatibleWithStandardLibrary}
13+
return jsonGoccy{}
1614
}
1715

1816
func MarshalKeepOptionalEmpty(v any) ([]byte, error) {

modules/lfs/http_client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func TestHTTPClientDownload(t *testing.T) {
193193
},
194194
{
195195
endpoint: "https://invalid-json-response.io",
196-
expectedError: "/(invalid json|jsontext: invalid character)/",
196+
expectedError: "/(invalid json|invalid character)/",
197197
},
198198
{
199199
endpoint: "https://valid-batch-request-download.io",
@@ -301,7 +301,7 @@ func TestHTTPClientUpload(t *testing.T) {
301301
},
302302
{
303303
endpoint: "https://invalid-json-response.io",
304-
expectedError: "/(invalid json|jsontext: invalid character)/",
304+
expectedError: "/(invalid json|invalid character)/",
305305
},
306306
{
307307
endpoint: "https://valid-batch-request-upload.io",

0 commit comments

Comments
 (0)