laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/pysim/+/35614?usp=email )

Change subject: pySim.utils: Support datetime.datetime in JsonEncoder
......................................................................

pySim.utils: Support datetime.datetime in JsonEncoder

Change-Id: I6223475cec8eb45c6fc4278109ad9dd1cb557800
---
M pySim/utils.py
1 file changed, 12 insertions(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/pySim/utils.py b/pySim/utils.py
index 581abf2..cf95dab 100644
--- a/pySim/utils.py
+++ b/pySim/utils.py
@@ -6,6 +6,7 @@
 import json
 import abc
 import string
+import datetime
 from io import BytesIO
 from typing import Optional, List, Dict, Any, Tuple, NewType

@@ -973,6 +974,8 @@
     def default(self, o):
         if isinstance(o, BytesIO) or isinstance(o, bytes) or isinstance(o, 
bytearray):
             return b2h(o)
+        elif isinstance(o, datetime.datetime):
+            return o.isoformat()
         return json.JSONEncoder.default(self, o)



--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35614?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I6223475cec8eb45c6fc4278109ad9dd1cb557800
Gerrit-Change-Number: 35614
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-MessageType: merged

Reply via email to