Skip to content

Commit 1de1943

Browse files
committed
fix SimpleNamespace serialization
1 parent b53bf9c commit 1de1943

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

multiversx_sdk_cli/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import tarfile
88
import zipfile
99
from pathlib import Path
10+
from types import SimpleNamespace
1011
from typing import Any, Optional, Protocol, Union, runtime_checkable
1112

1213
import toml
@@ -38,6 +39,9 @@ def default(self, o: Any) -> Any:
3839
return o.to_dictionary()
3940
if isinstance(o, bytes):
4041
return o.hex()
42+
# needed because sdk-py returns SimpleNamespace objects that the json library does not know to serialize
43+
if isinstance(o, SimpleNamespace):
44+
return o.__dict__
4145
return super().default(o)
4246

4347

0 commit comments

Comments
 (0)