I am new to pydantic and am stuck.
Below code is throwing error TypeError: Type is not JSON serializable: Person
from pydantic import BaseModel,Extra
from typing import Mapping, Optional, Any,List
from orjson import dumps
class Address(BaseModel):
place: str
class Person(BaseModel):
name: str
age: int
address: Mapping[str, str]={}
class Config:
anystr_strip_whitespace: True
extra: Extra.allow
allow_population_by_field_name: True
person={'name':'tom','age':12,"gender":"male"}
person=Person(**person)
person.address['place']='XYZ'
dict={'class':'X','person':person}
dumps(dict)
Any idea how to get this working ?