python newbie: I need to create an empty data model class, populate it with values and then convert it to JSON string, however i am missing something important here. see error below
my data class:
from pydantic import BaseModelclass ServiceInfo(BaseModel): SerialNumber: str OS: strclass ItemInfo(BaseModel): Name: str Version: strclass AppInfo(BaseModel): serviceInfo: ServiceInfo itemInfo: ItemInfothis is how i attempt to use the data model. i simplified for brevity, but there is a lot of logic here how this data model gets populated:
def myfunction() info = AppInfo() # <-- ERROR HERE "2 validation errors for ServiceInfo and ItemInfo" info.serviceInfo.SerialNumber = GetSerial() info.serviceInfo.OS = "OS 3.19" info.itemInfo.Name = GetName() info.itemInfo.Version = GetVersion() return info.jsonthank you in advance