0
0
LangChainframework~10 mins

JsonOutputParser for structured data in LangChain - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the JsonOutputParser from langchain.

LangChain
from langchain.output_parsers import [1]
Drag options to blanks, or click blank then click option'
AJsonOutputParser
BOutputParser
CJsonParser
DJsonDataParser
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'JsonParser' instead of 'JsonOutputParser'.
Importing from the wrong module.
2fill in blank
medium

Complete the code to create a JsonOutputParser instance with a given schema.

LangChain
parser = JsonOutputParser([1]=schema)
Drag options to blanks, or click blank then click option'
Aschema
Boutput_schema
Cjson_schema
Dschema_json
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'output_schema' or 'json_schema' instead of 'schema'.
Passing the schema as a positional argument.
3fill in blank
hard

Fix the error in the code to parse a JSON string using the parser.

LangChain
result = parser.[1](json_string)
Drag options to blanks, or click blank then click option'
Aparse_json
Bparse_output
Cload
Dparse
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'load' which is for file reading.
Using 'parse_json' which does not exist.
4fill in blank
hard

Fill both blanks to define a JSON schema and create the parser.

LangChain
schema = [1](type="object", properties={"name": {"type": "string"}})
parser = JsonOutputParser([2]=schema)
Drag options to blanks, or click blank then click option'
AJSONSchemaType
Bschema
Cjson_schema
Dschema_type
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong class name for schema.
Passing schema with wrong parameter name.
5fill in blank
hard

Fill both blanks to parse JSON output and extract the 'name' field.

LangChain
parsed = parser.[1](json_output)
name = parsed"name"
print([2])
Drag options to blanks, or click blank then click option'
Aparse
B[
Cname
D.get(
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot notation instead of brackets for dictionary access.
Printing the wrong variable.