| 308 | const double value = as_number(); |
| 309 | if (!std::isfinite(value) || std::floor(value) != value) { |
| 310 | throw std::runtime_error("json number is not an integer"); |
| 311 | } |
| 312 | return static_cast<int64_t>(value); |
| 313 | } |
| 314 | |
| 315 | float Value::as_f32() const { |
| 316 | return static_cast<float>(as_number()); |
| 317 | } |
| 318 | |
| 319 | const std::string & Value::as_string() const { |
| 320 | if (!is_string()) { |
| 321 | throw std::runtime_error("json value is not a string"); |
| 322 | } |
| 323 | return string_value_; |
| 324 | } |
| 325 | |
| 326 | const Value::Array & Value::as_array() const { |
no test coverage detected