Skip to content

Commit

Permalink
Use decoder with json.Number support
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
  • Loading branch information
peterbroadhurst committed Oct 22, 2024
1 parent 221d03d commit 68cbe18
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@ func (pa ParameterArray) ParseJSON(data []byte) (*ComponentValue, error) {

func (pa ParameterArray) ParseJSONCtx(ctx context.Context, data []byte) (*ComponentValue, error) {
var jsonTree interface{}
err := json.Unmarshal(data, &jsonTree)
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.UseNumber()
err := decoder.Decode(&jsonTree)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ func TestParseJSONArrayLotsOfTypes(t *testing.T) {
func TestParseJSONBadData(t *testing.T) {
inputs := testABI(t, sampleABI1)[0].Inputs
_, err := inputs.ParseJSON([]byte(`{`))
assert.Regexp(t, "unexpected end", err)
assert.Regexp(t, "unexpected EOF", err)

}

Expand Down

0 comments on commit 68cbe18

Please sign in to comment.