Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions jsonq.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jsonq

import (
"encoding/json"
"fmt"
"strconv"
)
Expand Down Expand Up @@ -41,6 +42,8 @@ func floatFromInterface(val interface{}) (float64, error) {
if err == nil {
return fval, nil
}
case json.Number:
return val.(json.Number).Float64()
}
return 0.0, fmt.Errorf("Expected numeric value for Float, got \"%v\"\n", val)
}
Expand All @@ -57,6 +60,9 @@ func intFromInterface(val interface{}) (int, error) {
}
case int:
return val.(int), nil
case json.Number:
i, err := val.(json.Number).Int64()
return int(i), err
}
return 0, fmt.Errorf("Expected numeric value for Int, got \"%v\"\n", val)
}
Expand Down