parse_and_check_json_markdown() — langchain Function Reference
Architecture documentation for the parse_and_check_json_markdown() function in json.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 2f7cfdad_4633_8189_c0c2_fc7e4941b8a9["parse_and_check_json_markdown()"] 20a5fe84_8249_f1df_53f0_7f22870f123f["json.py"] 2f7cfdad_4633_8189_c0c2_fc7e4941b8a9 -->|defined in| 20a5fe84_8249_f1df_53f0_7f22870f123f 2f7cfdad_4633_8189_c0c2_fc7e4941b8a9["parse_and_check_json_markdown()"] 2f7cfdad_4633_8189_c0c2_fc7e4941b8a9 -->|calls| 2f7cfdad_4633_8189_c0c2_fc7e4941b8a9 2f7cfdad_4633_8189_c0c2_fc7e4941b8a9["parse_and_check_json_markdown()"] 2f7cfdad_4633_8189_c0c2_fc7e4941b8a9 -->|calls| 2f7cfdad_4633_8189_c0c2_fc7e4941b8a9 0674c31d_4e25_0239_78af_91c5993e3cb3["parse_json_markdown()"] 2f7cfdad_4633_8189_c0c2_fc7e4941b8a9 -->|calls| 0674c31d_4e25_0239_78af_91c5993e3cb3 style 2f7cfdad_4633_8189_c0c2_fc7e4941b8a9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/utils/json.py lines 194–228
def parse_and_check_json_markdown(text: str, expected_keys: list[str]) -> dict:
"""Parse and check a JSON string from a Markdown string.
Checks that it contains the expected keys.
Args:
text: The Markdown string.
expected_keys: The expected keys in the JSON string.
Returns:
The parsed JSON object as a Python dictionary.
Raises:
OutputParserException: If the JSON string is invalid or does not contain
the expected keys.
"""
try:
json_obj = parse_json_markdown(text)
except json.JSONDecodeError as e:
msg = f"Got invalid JSON object. Error: {e}"
raise OutputParserException(msg) from e
if not isinstance(json_obj, dict):
error_message = (
f"Expected JSON object (dict), but got: {type(json_obj).__name__}. "
)
raise OutputParserException(error_message, llm_output=text)
for key in expected_keys:
if key not in json_obj:
msg = (
f"Got invalid return object. Expected key `{key}` "
f"to be present, but got {json_obj}"
)
raise OutputParserException(msg)
return json_obj
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does parse_and_check_json_markdown() do?
parse_and_check_json_markdown() is a function in the langchain codebase, defined in libs/core/langchain_core/utils/json.py.
Where is parse_and_check_json_markdown() defined?
parse_and_check_json_markdown() is defined in libs/core/langchain_core/utils/json.py at line 194.
What does parse_and_check_json_markdown() call?
parse_and_check_json_markdown() calls 2 function(s): parse_and_check_json_markdown, parse_json_markdown.
What calls parse_and_check_json_markdown()?
parse_and_check_json_markdown() is called by 1 function(s): parse_and_check_json_markdown.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free