parse_and_check_json_markdown#

langchain_core.utils.json.parse_and_check_json_markdown(text: str, expected_keys: list[str]) dict[source]#

Parse a JSON string from a Markdown string and check that it contains the expected keys.

Parameters:
  • text (str) – The Markdown string.

  • expected_keys (list[str]) – 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.

Return type:

dict