1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Represent datetime and enum in JSON for Pydantic

Discussão em 'Python' iniciado por Stack, Setembro 13, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to create a Pydantic schema via Python. Not with the data themselves but the JSON reprensentation of a schema and then I pass it to the generate method of datamodel_code_generator module.

    However, I am not sure how the JSON should represent date, datetime and Enum values. In the Pydantic documentation everything is just the different module type (datetime.date, datetime.datetime and Enum)

    However, the fact that I am building a JSON before using the generate method make me need to transform these element in their JSON representation. Not sure if this is supported or possible.

    Continue reading...

Compartilhe esta Página