Skip to content

Commit

Permalink
Fix json decoder
Browse files Browse the repository at this point in the history
replace std json to json Iter

Fix CI failure
  • Loading branch information
AlexiaChen committed May 15, 2021
1 parent ca53337 commit 3af4780
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
github.com/hashicorp/go-version v1.2.0
github.com/hashicorp/golang-lru v0.5.4
github.com/ipfs/go-ds-badger v0.2.4
github.com/json-iterator/go v1.1.10
github.com/libp2p/go-libp2p v0.13.0
github.com/libp2p/go-libp2p-core v0.8.0
github.com/libp2p/go-libp2p-crypto v0.1.0
Expand Down
6 changes: 4 additions & 2 deletions rpc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/numeric"
"github.com/harmony-one/harmony/shard"
jsoniter "github.com/json-iterator/go"
)

// CallArgs represents the arguments for a call.
Expand Down Expand Up @@ -101,11 +102,12 @@ type StructuredResponse = map[string]interface{}
// NewStructuredResponse creates a structured response from the given input
func NewStructuredResponse(input interface{}) (StructuredResponse, error) {
var objMap StructuredResponse
dat, err := json.Marshal(input)
var jsonIter = jsoniter.ConfigCompatibleWithStandardLibrary
dat, err := jsonIter.Marshal(input)
if err != nil {
return nil, err
}
d := json.NewDecoder(bytes.NewReader(dat))
d := jsonIter.NewDecoder(bytes.NewReader(dat))
d.UseNumber()
err = d.Decode(&objMap)
if err != nil {
Expand Down

0 comments on commit 3af4780

Please sign in to comment.