Skip to content

Commit

Permalink
CP-49349: Go SDK: Allow spaces in special value of float type
Browse files Browse the repository at this point in the history
Some special values of float standing in JSON are handled specifically.
This commit allows the special values contain spaces.

Signed-off-by: Ming Lu <[email protected]>
  • Loading branch information
minglumlu committed May 30, 2024
1 parent 3a61d23 commit a9b74ad
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ocaml/sdk-gen/go/autogen/src/jsonrpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"net/http"
"net/url"
"os"
"regexp"
"strings"
"time"
)
Expand Down Expand Up @@ -66,9 +67,12 @@ func (client *rpcClient) newRequest(ctx context.Context, req interface{}) (*http

func convertUnhandledJSONData(jsonBytes []byte) []byte {
jsonString := string(jsonBytes)
jsonString = strings.ReplaceAll(jsonString, ":Infinity", ":\"+Inf\"")
jsonString = strings.ReplaceAll(jsonString, ":-Infinity", ":\"-Inf\"")
jsonString = strings.ReplaceAll(jsonString, ":NaN", ":\"NaN\"")
re := regexp.MustCompile(`:[ ]*-Infinity`)
jsonString = re.ReplaceAllString(jsonString, `:"-Inf"`)
re = regexp.MustCompile(`:[ +]*Infinity`)
jsonString = re.ReplaceAllString(jsonString, `:"+Inf"`)
re = regexp.MustCompile(`:[ ]*NaN`)
jsonString = re.ReplaceAllString(jsonString, `:"NaN"`)

return []byte(jsonString)
}
Expand Down

0 comments on commit a9b74ad

Please sign in to comment.