simplify weigh_search() function

Use JSON arrays which can have mixed types and therefore have
a more logical structure than separate arrays. Avoid JSON dicts
because of their verboseness.
This commit is contained in:
Sarah Hoffmann
2023-12-05 16:07:56 +01:00
parent 05e47fbb28
commit c41f2fed21
3 changed files with 20 additions and 15 deletions

View File

@@ -76,8 +76,8 @@ class JsonWriter:
def end_array(self) -> 'JsonWriter':
""" Write the closing bracket of a JSON array.
"""
assert self.pending in (',', '[', '')
if self.pending == '[':
assert self.pending in (',', '[', ']', ')', '')
if self.pending not in (',', ''):
self.data.write(self.pending)
self.pending = ']'
return self