JSONReader#

class llama_index.readers.JSONReader(levels_back: Optional[int] = None, collapse_length: Optional[int] = None, ensure_ascii: bool = False, is_jsonl: Optional[bool] = False)#

Bases: BaseReader

JSON reader.

Reads JSON documents with options to help suss out relationships between nodes.

Parameters
  • levels_back (int) – the number of levels to go back in the JSON tree, 0 if you want all levels. If levels_back is None, then we just format the JSON and make each line an embedding

  • collapse_length (int) – the maximum number of characters a JSON fragment would be collapsed in the output (levels_back needs to be not None) ex: if collapse_length = 10, and input is {a: [1, 2, 3], b: {“hello”: “world”, “foo”: “bar”}} then a would be collapsed into one line, while b would not. Recommend starting around 100 and then adjusting from there.

  • is_jsonl (Optional[bool]) – If True, indicates that the file is in JSONL format.

  • False. (Defaults to) –

Methods Summary

load_data(input_file)

Load data from the input file.

Methods Documentation

load_data(input_file: str) List[Document]#

Load data from the input file.