Remove spaces from JSON output
This commit is contained in:
@ -81,8 +81,9 @@ class CSVlog(LOGlog):
|
|||||||
# JSON logging
|
# JSON logging
|
||||||
#
|
#
|
||||||
class JSONlog(LOGlog):
|
class JSONlog(LOGlog):
|
||||||
def __init__(self):
|
def __init__(self, quoted=0):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.quoted = quoted
|
||||||
|
|
||||||
def make(self, dire="logs", basename="log-", ext="json"):
|
def make(self, dire="logs", basename="log-", ext="json"):
|
||||||
return super().make(dire, basename, ext)
|
return super().make(dire, basename, ext)
|
||||||
@ -94,8 +95,10 @@ class JSONlog(LOGlog):
|
|||||||
super().header(str)
|
super().header(str)
|
||||||
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
# data['timestamp'] = time()
|
if self.quoted:
|
||||||
super().write(json.dumps(data))
|
super().write("'" + json.dumps(data, separators=(',', ':')) + "'")
|
||||||
|
else:
|
||||||
|
super().write(json.dumps(data, separators=(',', ':')))
|
||||||
|
|
||||||
def read(self, ):
|
def read(self, ):
|
||||||
return json.loads(super().read())
|
return json.loads(super().read())
|
||||||
|
|||||||
Reference in New Issue
Block a user