From 4048d2f2b7e4db1ce155f47ba0973566b45df762 Mon Sep 17 00:00:00 2001 From: boyce Date: Thu, 16 Jul 2020 11:22:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8D=87=E5=BC=95=E6=93=8E=E6=80=A7?= =?UTF-8?q?=E8=83=BD-=E6=9B=BF=E6=8D=A2json=E6=A0=87=E5=87=86=E5=BA=93?= =?UTF-8?q?=E4=B8=BAiterator/go=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cluster/parsecfg.go | 4 +++- rpc/jsonprocessor.go | 4 +++- sysservice/httpservice.go | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cluster/parsecfg.go b/cluster/parsecfg.go index 893a3f2..2a62b49 100644 --- a/cluster/parsecfg.go +++ b/cluster/parsecfg.go @@ -1,14 +1,16 @@ package cluster import ( - "encoding/json" "fmt" "github.com/duanhf2012/origin/log" "github.com/duanhf2012/origin/rpc" + jsoniter "github.com/json-iterator/go" "io/ioutil" "strings" ) +var json = jsoniter.ConfigCompatibleWithStandardLibrary + func (slf *Cluster) ReadClusterConfig(filepath string) (*SubNet,error) { c := &SubNet{} d, err := ioutil.ReadFile(filepath) diff --git a/rpc/jsonprocessor.go b/rpc/jsonprocessor.go index 107964e..3fd2247 100644 --- a/rpc/jsonprocessor.go +++ b/rpc/jsonprocessor.go @@ -1,10 +1,12 @@ package rpc import ( - "encoding/json" + jsoniter "github.com/json-iterator/go" "sync" ) +var json = jsoniter.ConfigCompatibleWithStandardLibrary + type JsonProcessor struct { } diff --git a/sysservice/httpservice.go b/sysservice/httpservice.go index be01f75..bf53247 100644 --- a/sysservice/httpservice.go +++ b/sysservice/httpservice.go @@ -1,12 +1,12 @@ package sysservice import ( - "encoding/json" "fmt" "github.com/duanhf2012/origin/event" "github.com/duanhf2012/origin/network" "github.com/duanhf2012/origin/service" "github.com/duanhf2012/origin/util/uuid" + jsoniter "github.com/json-iterator/go" "io" "io/ioutil" "net/http" @@ -15,6 +15,8 @@ import ( "time" ) +var json = jsoniter.ConfigCompatibleWithStandardLibrary + var Default_ReadTimeout time.Duration = time.Second*10 var Default_WriteTimeout time.Duration = time.Second*10 var Default_ProcessTimeout time.Duration = time.Second*10