Use contextjson

This commit is contained in:
世界
2023-12-01 20:15:11 +08:00
parent 7a0456b895
commit 2fb4d26f9f
13 changed files with 37 additions and 14 deletions

View File

@@ -1,10 +1,10 @@
package badjsonmerge
import (
"encoding/json"
"reflect"
"github.com/sagernet/sing-box/common/badjson"
"github.com/sagernet/sing-box/common/json"
"github.com/sagernet/sing-box/option"
E "github.com/sagernet/sing/common/exceptions"
)

21
common/json/context.go Normal file
View File

@@ -0,0 +1,21 @@
//go:build go1.21 && !without_contextjson
package json
import "github.com/sagernet/sing-box/common/contextjson"
var (
Marshal = json.Marshal
Unmarshal = json.Unmarshal
NewEncoder = json.NewEncoder
NewDecoder = json.NewDecoder
)
type (
Encoder = json.Encoder
Decoder = json.Decoder
Token = json.Token
Delim = json.Delim
SyntaxError = json.SyntaxError
RawMessage = json.RawMessage
)

View File

@@ -1,3 +1,5 @@
//go:build !go1.21 || without_contextjson
package json
import "encoding/json"
@@ -15,4 +17,5 @@ type (
Token = json.Token
Delim = json.Delim
SyntaxError = json.SyntaxError
RawMessage = json.RawMessage
)