mirror of
https://github.com/go-gitea/gitea
synced 2025-07-07 11:07:20 +00:00
Migrate to use jsoniter instead of encoding/json (#14841)
* Migrate to use jsoniter * fix tests * update gitea.com/go-chi/binding Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
@ -5,8 +5,9 @@
|
||||
package queue
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
// Mappable represents an interface that can MapTo another interface
|
||||
@ -19,6 +20,7 @@ type Mappable interface {
|
||||
// It will tolerate the cfg being passed as a []byte or string of a json representation of the
|
||||
// exemplar or the correct type of the exemplar itself
|
||||
func toConfig(exemplar, cfg interface{}) (interface{}, error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
|
||||
// First of all check if we've got the same type as the exemplar - if so it's all fine.
|
||||
if reflect.TypeOf(cfg).AssignableTo(reflect.TypeOf(exemplar)) {
|
||||
@ -66,6 +68,7 @@ func toConfig(exemplar, cfg interface{}) (interface{}, error) {
|
||||
|
||||
// unmarshalAs will attempt to unmarshal provided bytes as the provided exemplar
|
||||
func unmarshalAs(bs []byte, exemplar interface{}) (data Data, err error) {
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
if exemplar != nil {
|
||||
t := reflect.TypeOf(exemplar)
|
||||
n := reflect.New(t)
|
||||
|
Reference in New Issue
Block a user