From 921cfd92fc8bc320fc100b57e079b4cc5a9fa753 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simon=20K=C3=BCnzel?= <simonk@fsmpi.rwth-aachen.de>
Date: Wed, 22 May 2024 15:04:06 +0200
Subject: [PATCH] Allow default values in json

---
 src/api/miscellaneous/json.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/api/miscellaneous/json.py b/src/api/miscellaneous/json.py
index 10ec494..5e1c055 100644
--- a/src/api/miscellaneous/json.py
+++ b/src/api/miscellaneous/json.py
@@ -90,10 +90,14 @@ class CJsonObject(CJsonValue):
     def get_array(self, key: str) -> "CJsonArray":
         return self.get(key).as_array()
     
-    def get_bool(self, key: str) -> bool:
+    def get_bool(self, key: str, default: bool or None = None) -> bool:
+        if default is not None and not self.has(key):
+            return default
         return self.get(key).as_bool()
     
-    def get_sint32(self, key: str) -> int:
+    def get_sint32(self, key: str, default: int or None = None) -> int:
+        if default is not None and not self.has(key):
+            return default
         return self.get(key).as_sint32()
     
     def get_int(self, key: str, min_value: int, max_value: int, optional: bool = False) -> int or None:
-- 
GitLab