pub struct JSONLoader {
pub path: PathBuf,
pub content_key: Option<String>,
pub preserve_raw: bool,
}Expand description
JSON 文档加载器
支持加载 JSON 文件,可以指定某个字段作为文档内容。
- 对于 JSON 数组,每个元素生成一个文档
- 对于 JSON 对象,整个对象作为一个文档(或指定字段)
Fields§
§path: PathBufJSON 文件路径
content_key: Option<String>作为文档内容的字段名(可选) 如果指定,则提取该字段值作为 content
preserve_raw: bool是否保留原始 JSON 作为元数据
Implementations§
Source§impl JSONLoader
impl JSONLoader
Sourcepub fn new_with_content_key(
path: impl Into<PathBuf>,
content_key: impl Into<String>,
) -> Self
pub fn new_with_content_key( path: impl Into<PathBuf>, content_key: impl Into<String>, ) -> Self
Sourcepub fn with_preserve_raw(self, preserve: bool) -> Self
pub fn with_preserve_raw(self, preserve: bool) -> Self
设置是否保留原始 JSON
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JSONLoader
impl RefUnwindSafe for JSONLoader
impl Send for JSONLoader
impl Sync for JSONLoader
impl Unpin for JSONLoader
impl UnsafeUnpin for JSONLoader
impl UnwindSafe for JSONLoader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more