diff --git a/src/antares/service/api_services/link_api.py b/src/antares/service/api_services/link_api.py index 4118ded4..5f28787f 100644 --- a/src/antares/service/api_services/link_api.py +++ b/src/antares/service/api_services/link_api.py @@ -10,7 +10,6 @@ # # This file is part of the Antares project. -import json from types import MappingProxyType from typing import Optional @@ -113,7 +112,7 @@ def update_link_properties(self, link: Link, properties: LinkProperties) -> Link area1_id, area2_id = sorted([link.area_from.id, link.area_to.id]) raw_url = f"{self._base_url}/studies/{self.study_id}/raw?path=input/links/{area1_id}/properties/{area2_id}" try: - new_properties = json.loads(properties.model_dump_json(by_alias=True, exclude_none=True)) + new_properties = properties.model_dump(mode="json", by_alias=True, exclude_none=True) if not new_properties: return link.properties @@ -145,7 +144,7 @@ def update_link_ui(self, link: Link, ui: LinkUi) -> LinkUi: area1_id, area2_id = sorted([link.area_from.id, link.area_to.id]) raw_url = f"{self._base_url}/studies/{self.study_id}/raw?path=input/links/{area1_id}/properties/{area2_id}" try: - new_ui = json.loads(ui.model_dump_json(by_alias=True, exclude_none=True)) + new_ui = ui.model_dump(mode="json", by_alias=True, exclude_none=True) if not new_ui: return link.ui diff --git a/src/antares/service/api_services/study_api.py b/src/antares/service/api_services/study_api.py index adb5634b..027e92c8 100644 --- a/src/antares/service/api_services/study_api.py +++ b/src/antares/service/api_services/study_api.py @@ -10,7 +10,6 @@ # # This file is part of the Antares project. -import json from typing import Optional from antares.api_conf.api_conf import APIconf @@ -48,7 +47,7 @@ def _returns_study_settings( "playlist": ("playlist", None), } if settings: - json_settings = json.loads(settings.model_dump_json(by_alias=True, exclude_none=True)) + json_settings = settings.model_dump(mode="json", by_alias=True, exclude_none=True) if not json_settings and update: return None