| 976 | } // namespace |
| 977 | |
| 978 | Result<std::shared_ptr<Array>> ArrayFromJSONString(const std::shared_ptr<DataType>& type, |
| 979 | std::string_view json_string) { |
| 980 | std::shared_ptr<JSONConverter> converter; |
| 981 | RETURN_NOT_OK(GetConverter(type, &converter)); |
| 982 | |
| 983 | rj::Document json_doc; |
| 984 | json_doc.Parse<kParseFlags>(json_string.data(), json_string.length()); |
| 985 | if (json_doc.HasParseError()) { |
| 986 | return Status::Invalid("JSON parse error at offset ", json_doc.GetErrorOffset(), ": ", |
| 987 | GetParseError_En(json_doc.GetParseError())); |
| 988 | } |
| 989 | |
| 990 | // The JSON document should be an array, append it |
| 991 | RETURN_NOT_OK(converter->AppendValues(json_doc)); |
| 992 | std::shared_ptr<Array> out; |
| 993 | RETURN_NOT_OK(converter->Finish(&out)); |
| 994 | return out; |
| 995 | } |
| 996 | |
| 997 | Result<std::shared_ptr<Array>> ArrayFromJSONString(const std::shared_ptr<DataType>& type, |
| 998 | const std::string& json_string) { |