mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
fix: json number convert rule
Change-Id: I68a811b803631ef78b6b12fe548f98b676a10eb3
This commit is contained in:
@@ -69,7 +69,8 @@ func (p *parser) parseData(raw interface{}, variablesMapping map[string]interfac
|
|||||||
case reflect.String:
|
case reflect.String:
|
||||||
// json.Number
|
// json.Number
|
||||||
if rawValue, ok := raw.(json.Number); ok {
|
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
|
// other string
|
||||||
value := rawValue.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 (
|
const (
|
||||||
regexVariable = `[a-zA-Z_]\w*` // variable name should start with a letter or underscore
|
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
|
regexFunctionName = `[a-zA-Z_]\w*` // function name should start with a letter or underscore
|
||||||
|
|||||||
Reference in New Issue
Block a user