Open AlexSamarsky opened 1 year ago
i want to load json with key name 'from', make dataclasse with field "from_" and load it if config.reserved_names is True i found that nessesary when worked with JIRA API it returns change history json
data = { "field": "IssueParentAssociation", "fieldtype": "jira", "from": "88223", "fromString": "PRJ-1", "to": "88222", "toString": "PRJ-2" }
then make dataclass
@dataclass class HistoryItemJson: field: str fieldtype: str fieldId: Optional[str] from_: Optional[str] fromString: Optional[str] to: Optional[str] toString: Optional[str]
and simply load it result: HistoryItemJson = from_dict(data_class=HistoryItemJson, data=data, config=Config(type_hooks={datetime: datetime.fromisoformat}, reserved_names=True))
result: HistoryItemJson = from_dict(data_class=HistoryItemJson, data=data, config=Config(type_hooks={datetime: datetime.fromisoformat}, reserved_names=True))
i want to load json with key name 'from', make dataclasse with field "from_" and load it if config.reserved_names is True i found that nessesary when worked with JIRA API it returns change history json
then make dataclass
and simply load it
result: HistoryItemJson = from_dict(data_class=HistoryItemJson, data=data, config=Config(type_hooks={datetime: datetime.fromisoformat}, reserved_names=True))