Home / Function/ test_split_json() — langchain Function Reference

test_split_json() — langchain Function Reference

Architecture documentation for the test_split_json() function in test_text_splitters.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b73163d3_d7c0_1247_0792_47b53fb5e832["test_split_json()"]
  6d6b8ad4_1cfe_fbb0_e58e_76a50487c135["test_text_splitters.py"]
  b73163d3_d7c0_1247_0792_47b53fb5e832 -->|defined in| 6d6b8ad4_1cfe_fbb0_e58e_76a50487c135
  style b73163d3_d7c0_1247_0792_47b53fb5e832 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/text-splitters/tests/unit_tests/test_text_splitters.py lines 3162–3181

def test_split_json() -> None:
    """Test json text splitter."""
    max_chunk = 800
    splitter = RecursiveJsonSplitter(max_chunk_size=max_chunk)

    def random_val() -> str:
        return "".join(random.choices(string.ascii_letters, k=random.randint(4, 12)))

    test_data: Any = {
        "val0": random_val(),
        "val1": {f"val1{i}": random_val() for i in range(100)},
    }
    test_data["val1"]["val16"] = {f"val16{i}": random_val() for i in range(100)}

    # uses create_docs and split_text
    docs = splitter.create_documents(texts=[test_data])

    output = [len(doc.page_content) < max_chunk * 1.05 for doc in docs]
    expected_output = [True for doc in docs]
    assert output == expected_output

Domain

Subdomains

Frequently Asked Questions

What does test_split_json() do?
test_split_json() is a function in the langchain codebase, defined in libs/text-splitters/tests/unit_tests/test_text_splitters.py.
Where is test_split_json() defined?
test_split_json() is defined in libs/text-splitters/tests/unit_tests/test_text_splitters.py at line 3162.

Analyze Your Own Codebase

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

Try Supermodel Free