Support for Json Type
Closed this issue · 3 comments
alazaralemayehu commented
Description
class Person(BaseModel):
names: Json[Any]
person_json = '''
{
"first_name": "john",
"last_name": "Doe",
"nick_name": "lost"
}
'''
p = Person.json_parse(person_json)
This automatically converts the person_json
into pydantic Model. But I couldn't find the way to reverse this.
Goldziher commented
Hi, thanks for the issue. So the JSON is a dict - you mean you want to output the JSON as a string instead of a dict?
alazaralemayehu commented
Yes. For more info, I am talking about this feature https://pydantic-docs.helpmanual.io/usage/types/#json-type
Goldziher commented
So, I am not sure what is required here to be honest. Can you show me a code snippet that is failing to do what you need?