{"record":{"id":"5a84761d47a583e6","repo":"langchain-ai/langchain","slug":"expected-json-object-dict-but-got-type-json-o","errorCode":null,"errorMessage":"Expected JSON object (dict), but got: {type(json_obj).__name__}. ","messagePattern":"Expected JSON object \\(dict\\), but got: (.+?)\\. ","errorType":"exception","errorClass":"OutputParserException","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/utils/json.py","lineNumber":221,"sourceCode":"        expected_keys: The expected keys in the JSON string.\n\n    Returns:\n        The parsed JSON object as a Python dictionary.\n\n    Raises:\n        OutputParserException: If the JSON string is invalid or does not contain\n            the expected keys.\n    \"\"\"\n    try:\n        json_obj = parse_json_markdown(text)\n    except json.JSONDecodeError as e:\n        msg = f\"Got invalid JSON object. Error: {e}\"\n        raise OutputParserException(msg) from e\n    if not isinstance(json_obj, dict):\n        error_message = (\n            f\"Expected JSON object (dict), but got: {type(json_obj).__name__}. \"\n        )\n        raise OutputParserException(error_message, llm_output=text)\n\n    for key in expected_keys:\n        if key not in json_obj:\n            msg = (\n                f\"Got invalid return object. Expected key `{key}` \"\n                f\"to be present, but got {json_obj}\"\n            )\n            raise OutputParserException(msg)\n    return json_obj\n","sourceCodeStart":203,"sourceCodeEnd":231,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/utils/json.py#L203-L231","documentation":"Error \"Expected JSON object (dict), but got: {type(json_obj).__name__}. \" thrown in langchain-ai/langchain.","triggerScenarios":"Raised when parsed JSON output is not a JSON object (dict) as required, e.g. it is a list or scalar.","commonSituations":"See trigger scenarios.","solutions":["Return a JSON object (dict) at the top level, not a JSON array or scalar.","If the model returned a list, wrap it in an object, e.g. {\"items\": [...]}."],"exampleFix":"{\"items\": [1, 2, 3]}  # instead of [1, 2, 3]","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}