From 61fd9483238e6795d986e845c4916ad6cb420257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Mon, 17 Jan 2022 16:34:30 -0300 Subject: [PATCH] pykson: Defines __str__ for JsonObject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- pykson/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pykson/__init__.py b/pykson/__init__.py index 6df16e9..79e7426 100644 --- a/pykson/__init__.py +++ b/pykson/__init__.py @@ -725,6 +725,8 @@ def __init__(self, accept_unknown: bool = False, extra_attributes: Optional[List # Empty init will be replaced by meta class super(JsonObject, self).__init__() + def __str__(self): + return json.dumps(json.loads(Pykson().to_json(self)), indent=2, sort_keys=True) T = TypeVar('T', bound=JsonObject)