| 274 | |
| 275 | template <size_t kExpectedSize> |
| 276 | Status ProcessJsonArrayElements( |
| 277 | sj::array& json_array, const char* error_context, |
| 278 | const std::array<JsonElementHandler, kExpectedSize>& handlers) { |
| 279 | auto it = json_array.begin(); |
| 280 | auto end = json_array.end(); |
| 281 | |
| 282 | size_t index = 0; |
| 283 | for (const auto& handler : handlers) { |
| 284 | if (it == end) { |
| 285 | return Status::Invalid(error_context, " must have exactly ", kExpectedSize, |
| 286 | " elements, had ", index); |
| 287 | } |
| 288 | |
| 289 | ARROW_ASSIGN_OR_RAISE(sj::value element, |
| 290 | internal::ResolveSimdjsonResult<sj::value>( |
| 291 | *it, "Could not iterate elements of JSON array: ")); |
| 292 | RETURN_NOT_OK(handler(element)); |
| 293 | ++it; |
| 294 | ++index; |
| 295 | } |
| 296 | |
| 297 | if (it != end) { |
| 298 | return Status::Invalid(error_context, " must have exactly ", kExpectedSize, |
| 299 | " elements, had more"); |
| 300 | } |
| 301 | return Status::OK(); |
| 302 | } |
| 303 | |
| 304 | // ------------------------------------------------------------------------ |
| 305 | // Converter for int arrays |