GetInt returns the value retrieved by `Get`, cast to a int64 if possible. If key data type do not match, it will return an error. SYS-REQ-003, SYS-REQ-075, SYS-REQ-076, SYS-REQ-077, SYS-REQ-078
(data []byte, keys ...string)
| 2085 | // If key data type do not match, it will return an error. |
| 2086 | // SYS-REQ-003, SYS-REQ-075, SYS-REQ-076, SYS-REQ-077, SYS-REQ-078 |
| 2087 | func GetInt(data []byte, keys ...string) (val int64, err error) { |
| 2088 | v, t, _, e := Get(data, keys...) |
| 2089 | |
| 2090 | if e != nil { |
| 2091 | return 0, e |
| 2092 | } |
| 2093 | |
| 2094 | if t != Number { |
| 2095 | if t == Null { |
| 2096 | return 0, NullValueError |
| 2097 | } |
| 2098 | return 0, fmt.Errorf("Value is not a number: %s", string(v)) |
| 2099 | } |
| 2100 | |
| 2101 | return ParseInt(v) |
| 2102 | } |
| 2103 | |
| 2104 | // GetBoolean returns the value retrieved by `Get`, cast to a bool if possible. |
| 2105 | // The offset is the same as in `Get`. |