class Data(BaseModel):
val: int
Data.model_validate_json("not json")
Error:
pydantic.ValidationError: 1 validation error for Data
Input should be a valid JSON [type=json_invalid,
input_value='not json', input_type=str]

class Data(BaseModel):
val: int
Data.model_validate_json("not json")
Error:
pydantic.ValidationError: 1 validation error for Data
Input should be a valid JSON [type=json_invalid,
input_value='not json', input_type=str]
Fix:
Data.model_validate_json('{"val": 123}')
Tell us about your project and get help tailored to your problem.
Contact usEveryone can read. Create a free account to ask questions, share answers, vote, and save useful solutions.