pydantic~=2.9.2
from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar
# A simple student struct
class Student(BaseModel):
first_name: Optional[str] = Field(default=None, alias="firstName")
last_name: Optional[str] = Field(default=None, alias="lastName")
age: Optional[int] = Field(default=None, alias="age")
pass
input = Path('input.json').read_text()
student = Student.model_validate_json(input)
output = student.model_dump_json()
Path('output.json').write_text(output)