I have a data structure which consists of a dictionary with string keys, and the value for each key is a Pydantic model.
For example, the dictionary might look like this:
{
"hello": MyPydanticModel(name="hello"),
"there": MyPydanticModel(name="there")
}
I'm aware that I can call .json() to convert the Pydantic models into JSON, but what would be the most straightforward way to convert the dictionary to JSON. Would I need to use py2json or some other library?
Many thanks in advance.