normalizeJSONNumber converts a json.Number scalar (produced because the decoder runs with UseNumber) into an int for integers within the int64 range and a float64 otherwise. Non-number tokens are returned unchanged; a number representable as neither returns the json.Number.Float64 error.
(t interface{})
| 137 | // and a float64 otherwise. Non-number tokens are returned unchanged; a number |
| 138 | // representable as neither returns the json.Number.Float64 error. |
| 139 | func normalizeJSONNumber(t interface{}) (interface{}, error) { |
| 140 | n, ok := t.(json.Number) |
| 141 | if !ok { |
| 142 | return t, nil |
| 143 | } |
| 144 | if i, err := n.Int64(); err == nil { |
| 145 | return int(i), nil |
| 146 | } |
| 147 | f, err := n.Float64() |
| 148 | if err != nil { |
| 149 | return nil, err |
| 150 | } |
| 151 | return f, nil |
| 152 | } |
| 153 | |
| 154 | var errEndOfObject = fmt.Errorf("End of object") |
| 155 |
no outgoing calls
no test coverage detected