Introduce a function to extend from a JSON array of objects

This commit is contained in:
Kerollmops 2022-07-11 18:38:50 +02:00
parent dc61105554
commit a892a4a79c
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
6 changed files with 89 additions and 12 deletions

View file

@ -337,11 +337,8 @@ fn documents_from_jsonl(reader: impl Read) -> Result<Vec<u8>> {
fn documents_from_json(reader: impl Read) -> Result<Vec<u8>> {
let mut documents = DocumentsBatchBuilder::new(Vec::new());
let list: Vec<Object> = serde_json::from_reader(reader)?;
for object in list {
documents.append_json_object(&object)?;
}
documents.append_json_array(reader)?;
documents.into_inner().map_err(Into::into)
}