ordeq_pydantic
PydanticJSON
dataclass
¶
Bases: IO[BaseModel]
IO to load and save Pydantic models to JSON
Example usage:
1 2 3 4 5 6 7 8 9 10 11 12 | |
PydanticModel
dataclass
¶
Bases: IO[BaseModel]
IO to load and save Pydantic models from/to any IO that handles dictionaries.
Example usage:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Instead of using:
1 2 3 4 5 | |
you can also use:
1 2 3 4 | |
This uses the Pydantic JSON implementation which is more efficient for JSON files.
load(**load_options)
¶
Load the Pydantic model from the underlying IO.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**load_options
|
Any
|
Options to pass to the Pydantic model validation. |
{}
|
Returns:
| Type | Description |
|---|---|
BaseModel
|
The loaded Pydantic model. |
save(model, **save_options)
¶
Save the Pydantic model to the underlying IO.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
BaseModel
|
The Pydantic model to save. |
required |
**save_options
|
Any
|
Options to pass to the Pydantic model dump. |
{}
|