| 440 | } |
| 441 | |
| 442 | Result<std::vector<int64_t>> GetJsonIntArray(simdjson::dom::element value, |
| 443 | std::string_view name) { |
| 444 | ARROW_ASSIGN_OR_RAISE(auto array, GetJsonArray(value, name)); |
| 445 | |
| 446 | std::vector<int64_t> result; |
| 447 | result.reserve(array.size()); |
| 448 | |
| 449 | for (auto element : array) { |
| 450 | ARROW_ASSIGN_OR_RAISE(auto number, GetJsonInt(element, name, "integers")); |
| 451 | result.push_back(number); |
| 452 | } |
| 453 | |
| 454 | return result; |
| 455 | } |
| 456 | |
| 457 | Result<std::vector<std::optional<int64_t>>> GetJsonNullableIntArray( |
| 458 | simdjson::dom::element value, std::string_view name) { |
| 459 | ARROW_ASSIGN_OR_RAISE(auto array, GetJsonArray(value, name)); |
| 460 | |
| 461 | std::vector<std::optional<int64_t>> result; |
| 462 | result.reserve(array.size()); |
| 463 | |
| 464 | for (auto element : array) { |
| 465 | if (element.is_null()) { |
| 466 | result.emplace_back(std::nullopt); |
| 467 | } else { |
| 468 | ARROW_ASSIGN_OR_RAISE(auto number, GetJsonInt(element, name, "integers or nulls")); |
| 469 | result.emplace_back(number); |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | return result; |
| 474 | } |
| 475 | |
| 476 | Result<std::vector<std::string>> GetJsonStringArray(simdjson::dom::element value, |
| 477 | std::string_view name) { |
| 478 | ARROW_ASSIGN_OR_RAISE(auto array, GetJsonArray(value, name)); |
| 479 | |
| 480 | std::vector<std::string> result; |
| 481 | result.reserve(array.size()); |
| 482 | |
| 483 | for (auto element : array) { |
| 484 | if (!element.is_string()) { |
| 485 | return Status::Invalid(name, " must contain strings, got ", |
| 486 | JsonTypeName(element.type())); |
| 487 | } |
| 488 | |
| 489 | ARROW_ASSIGN_OR_RAISE( |
| 490 | auto string, |
| 491 | ResolveSimdjsonResult(element.get_string(), "Failed to get JSON string")); |
| 492 | result.emplace_back(string); |
| 493 | } |
| 494 | |
| 495 | return result; |
| 496 | } |
| 497 | |
| 498 | const char* JsonTypeName(simdjson::ondemand::json_type type) { |
| 499 | switch (type) { |