Toggle Menu
Prev Up Next

# `langchain_text_splitters.json`.RecursiveJsonSplitter

class langchain_text_splitters.json.RecursiveJsonSplitter(max_chunk_size: int = 2000, min_chunk_size: Optional[int] = None)

  Methods

  `__init__`([max_chunk_size, min_chunk_size]) |
  `create_documents`(texts[, convert_lists, ...]) | Create documents from a list of json objects (Dict).
  `split_json`(json_data[, convert_lists]) | Splits JSON into a list of JSON chunks
  `split_text`(json_data[, convert_lists]) | Splits JSON into a list of JSON formatted strings

  Parameters

    - max_chunk_size (int) –

    - min_chunk_size (Optional[int]) –

  __init__(max_chunk_size: int = 2000, min_chunk_size: Optional[int] = None)
    Parameters

      - max_chunk_size (int) –

      - min_chunk_size (Optional[int]) –

  create_documents(texts: List[Dict], convert_lists: bool = False, metadatas: Optional[List[dict]] = None) → List[Document]

    Create documents from a list of json objects (Dict).

    Parameters

      - texts (List[Dict]) –

      - convert_lists (bool) –

      - metadatas (Optional[List[dict]]) –

    Return type

      List[Document]

  split_json(json_data: Dict[str, Any], convert_lists: bool = False) → List[Dict]

    Splits JSON into a list of JSON chunks

    Parameters

      - json_data (Dict[str, Any]) –

      - convert_lists (bool) –

    Return type

      List[Dict]

  split_text(json_data: Dict[str, Any], convert_lists: bool = False) → List[str]

    Splits JSON into a list of JSON formatted strings

    Parameters

      - json_data (Dict[str, Any]) –

      - convert_lists (bool) –

    Return type

      List[str]

# Examples using RecursiveJsonSplitter

- This is a large nested json object and will be loaded as a python dict