Remove spaces from JSON output

This commit is contained in:
2021-04-28 10:10:15 -04:00
parent 7228eed810
commit 29ef7f63db

View File

@ -81,8 +81,9 @@ class CSVlog(LOGlog):
# JSON logging
#
class JSONlog(LOGlog):
def __init__(self):
def __init__(self, quoted=0):
super().__init__()
self.quoted = quoted
def make(self, dire="logs", basename="log-", ext="json"):
return super().make(dire, basename, ext)
@ -94,8 +95,10 @@ class JSONlog(LOGlog):
super().header(str)
def write(self, data):
# data['timestamp'] = time()
super().write(json.dumps(data))
if self.quoted:
super().write("'" + json.dumps(data, separators=(',', ':')) + "'")
else:
super().write(json.dumps(data, separators=(',', ':')))
def read(self, ):
return json.loads(super().read())