Skip to content

Support scientific notation (YeX) #1952

Open
@swelborn

Description

@swelborn

Describe the bug
Scientific notation in json converts to str in model:

class Model(BaseModel):
    hello: str

To Reproduce

Example json:

{
    "hello": 1e-9
}

Used commandline:

$ datamodel-codegen --input-file-type json --input gen/test-meta.json --output gen/test_scientific_notation.py

Expected behavior
Expected float.

Version:

  • OS: macOS
  • Python version: 3.11.9
  • datamodel-code-generator version: 0.25.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions