mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
fix: json number convert rule
Change-Id: I68a811b803631ef78b6b12fe548f98b676a10eb3
This commit is contained in:
13
parser.go
13
parser.go
@@ -69,7 +69,8 @@ func (p *parser) parseData(raw interface{}, variablesMapping map[string]interfac
|
||||
case reflect.String:
|
||||
// json.Number
|
||||
if rawValue, ok := raw.(json.Number); ok {
|
||||
return parseJSONNumber(rawValue)
|
||||
// use the same rule as json.Unmarshal (float64, for JSON numbers)
|
||||
return rawValue.Float64()
|
||||
}
|
||||
// other string
|
||||
value := rawValue.String()
|
||||
@@ -108,16 +109,6 @@ func (p *parser) parseData(raw interface{}, variablesMapping map[string]interfac
|
||||
}
|
||||
}
|
||||
|
||||
func parseJSONNumber(raw json.Number) (interface{}, error) {
|
||||
if strings.Contains(raw.String(), ".") {
|
||||
// float64
|
||||
return raw.Float64()
|
||||
} else {
|
||||
// int64
|
||||
return raw.Int64()
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
regexVariable = `[a-zA-Z_]\w*` // variable name should start with a letter or underscore
|
||||
regexFunctionName = `[a-zA-Z_]\w*` // function name should start with a letter or underscore
|
||||
|
||||
Reference in New Issue
Block a user