# main.py
import json
import pydantic
from fastapi import FastAPI, status
from fastapi.responses import JSONResponse

app = FastAPI()

class MyObject(pydantic.BaseModel):
      field1: int
      field2: int
      field3: int
      field4: int
      field5: int
      field6: int
      field7: int
      field8: int
      field9: int
      field10: int

@app.post("/")
async def create_object(data: dict) -> JSONResponse:
      obj = MyObject(**data)
      data_dict = obj.dict(exclude_unset=True)
      return JSONResponse(data_dict, status_code=201)

if __name__ == '__main__':
      # read json file
      with open('data.json') as f:
          json_data = json.load(f)

      # create objects with pydantic
      objects = [MyObject(**obj) for obj in json_data