From 9badae103808bef9d6b00abc2753be4722e5cfd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20K=C3=BCnzel?= <simonk@fsmpi.rwth-aachen.de> Date: Thu, 24 Apr 2025 00:25:31 +0200 Subject: [PATCH] Fix bug in JSON deserialization: Don't modify input --- .../src/videoag_common/miscellaneous/json_serializable.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common_py/src/videoag_common/miscellaneous/json_serializable.py b/common_py/src/videoag_common/miscellaneous/json_serializable.py index 82ca3c3..dd64215 100644 --- a/common_py/src/videoag_common/miscellaneous/json_serializable.py +++ b/common_py/src/videoag_common/miscellaneous/json_serializable.py @@ -426,8 +426,8 @@ class TypedJsonDataClass[T: str or "JsonSerializableEnum"](JsonDataClass): if type_str not in cls.__classes_by_json_str_type__: json.get("type").raise_error(f"Unknown type '{type_str}'. Possible values: {', '.join(cls.__classes_by_json_str_type__.keys())}") - # Remove type from data - raw_json = json.get_unsafe_data() + # Remove type from data on a COPY! Very IMPORTANT, otherwise weird things happen! + raw_json = dict(json.get_unsafe_data()) raw_json.pop("type") json = CJsonObject(raw_json) return cls.__classes_by_json_str_type__[type_str].from_json(json, _do_type_check=False) -- GitLab