From 311f3705bede72da3978d24042d46e900a92e15b Mon Sep 17 00:00:00 2001 From: Anuj Jain Date: Mon, 10 Jul 2017 17:45:48 +0530 Subject: [PATCH] Fix reflection for numbers encoded as strings --- utils.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils.go b/utils.go index 1ec5b06..f6c127c 100644 --- a/utils.go +++ b/utils.go @@ -213,6 +213,15 @@ func toNumber(value interface{}) (float64, bool) { x = float64(value.(float32)) } return x, true + case string: + var x float64 + var err error + x, err = strconv.ParseFloat(value, 64) + if (err == nil) { + return x, true + } else { + return 0.0, false + } case int, int8, int16, int32, int64: i := reflect.ValueOf(value) return float64(i.Int()), true