-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert to goccy json, because it is more compatible
- Loading branch information
Showing
5 changed files
with
14 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
package json | ||
|
||
import ( | ||
"github.com/bytedance/sonic" | ||
"github.com/goccy/go-json" | ||
) | ||
|
||
type Marshaler struct { | ||
api sonic.API | ||
} | ||
type Marshaler struct{} | ||
|
||
func NewMarshaler() Marshaler { | ||
return Marshaler{ | ||
api: sonic.ConfigDefault, | ||
} | ||
return Marshaler{} | ||
} | ||
|
||
func (jm Marshaler) Marshal(m any) ([]byte, error) { | ||
return jm.api.Marshal(m) | ||
return json.MarshalNoEscape(m) | ||
} | ||
|
||
func (jm Marshaler) Unmarshal(data []byte, m any) error { | ||
return jm.api.Unmarshal(data, m) | ||
return json.Unmarshal(data, m) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
package json | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/bytedance/sonic" | ||
"github.com/goccy/go-json" | ||
) | ||
|
||
type RawMessage = json.RawMessage | ||
|
||
func Marshal(v any) ([]byte, error) { | ||
return sonic.ConfigDefault.Marshal(v) | ||
return json.MarshalNoEscape(v) | ||
} | ||
|
||
func MarshalIndent(v any, prefix, indent string) ([]byte, error) { | ||
return sonic.ConfigDefault.MarshalIndent(v, prefix, indent) | ||
return json.MarshalIndent(v, prefix, indent) | ||
} | ||
|
||
func Unmarshal(data []byte, v any) error { | ||
return sonic.ConfigDefault.Unmarshal(data, v) | ||
return json.UnmarshalNoEscape(data, v) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters