Add with_std_json build tag
This commit is contained in:
@@ -3,9 +3,8 @@ package badjson
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/sagernet/sing-box/common/json"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
)
|
||||
|
||||
type JSONArray[T any] []T
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package badjson
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing-box/common/json"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
)
|
||||
|
||||
func decodeJSON(decoder *json.Decoder) (any, error) {
|
||||
|
||||
@@ -4,10 +4,9 @@ import (
|
||||
"bytes"
|
||||
"strings"
|
||||
|
||||
"github.com/sagernet/sing-box/common/json"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
"github.com/sagernet/sing/common/x/linkedhashmap"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
)
|
||||
|
||||
type JSONObject struct {
|
||||
|
||||
20
common/json/gojson.go
Normal file
20
common/json/gojson.go
Normal file
@@ -0,0 +1,20 @@
|
||||
//go:build !with_std_json
|
||||
|
||||
package json
|
||||
|
||||
import "github.com/goccy/go-json"
|
||||
|
||||
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
|
||||
)
|
||||
20
common/json/std.go
Normal file
20
common/json/std.go
Normal file
@@ -0,0 +1,20 @@
|
||||
//go:build with_std_json
|
||||
|
||||
package json
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
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
|
||||
)
|
||||
Reference in New Issue
Block a user