Home / Function/ split_json() — langchain Function Reference

split_json() — langchain Function Reference

Architecture documentation for the split_json() function in json.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  e3fb30a1_bf0b_b803_4160_e962db65ecfe["split_json()"]
  6fcdab9c_3ecd_51f0_a2ae_3b0c8bfac048["RecursiveJsonSplitter"]
  e3fb30a1_bf0b_b803_4160_e962db65ecfe -->|defined in| 6fcdab9c_3ecd_51f0_a2ae_3b0c8bfac048
  e3fb30a1_bf0b_b803_4160_e962db65ecfe["split_json()"]
  e3fb30a1_bf0b_b803_4160_e962db65ecfe -->|calls| e3fb30a1_bf0b_b803_4160_e962db65ecfe
  03a7225b_8bf6_9fff_f8d4_0a36c276bded["split_text()"]
  03a7225b_8bf6_9fff_f8d4_0a36c276bded -->|calls| e3fb30a1_bf0b_b803_4160_e962db65ecfe
  d81ccdd5_8091_6de6_425e_3dba9ac5dc9f["_json_split()"]
  e3fb30a1_bf0b_b803_4160_e962db65ecfe -->|calls| d81ccdd5_8091_6de6_425e_3dba9ac5dc9f
  ab35e0b0_5a75_02e6_13a4_6e87c8da8bfc["_list_to_dict_preprocessing()"]
  e3fb30a1_bf0b_b803_4160_e962db65ecfe -->|calls| ab35e0b0_5a75_02e6_13a4_6e87c8da8bfc
  e3fb30a1_bf0b_b803_4160_e962db65ecfe["split_json()"]
  e3fb30a1_bf0b_b803_4160_e962db65ecfe -->|calls| e3fb30a1_bf0b_b803_4160_e962db65ecfe
  style e3fb30a1_bf0b_b803_4160_e962db65ecfe fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/text-splitters/langchain_text_splitters/json.py lines 116–139

    def split_json(
        self,
        json_data: dict[str, Any],
        convert_lists: bool = False,  # noqa: FBT001,FBT002
    ) -> list[dict[str, Any]]:
        """Splits JSON into a list of JSON chunks.

        Args:
            json_data: The JSON data to be split.
            convert_lists: Whether to convert lists in the JSON to dictionaries
                before splitting.

        Returns:
            A list of JSON chunks.
        """
        if convert_lists:
            chunks = self._json_split(self._list_to_dict_preprocessing(json_data))
        else:
            chunks = self._json_split(json_data)

        # Remove the last chunk if it's empty
        if not chunks[-1]:
            chunks.pop()
        return chunks

Subdomains

Frequently Asked Questions

What does split_json() do?
split_json() is a function in the langchain codebase, defined in libs/text-splitters/langchain_text_splitters/json.py.
Where is split_json() defined?
split_json() is defined in libs/text-splitters/langchain_text_splitters/json.py at line 116.
What does split_json() call?
split_json() calls 3 function(s): _json_split, _list_to_dict_preprocessing, split_json.
What calls split_json()?
split_json() is called by 2 function(s): split_json, split_text.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free