Commit 9279e27c authored by Ryan Herbert's avatar Ryan Herbert Committed by Mikaël Salson
Browse files fix comma delimitation on output

The introduction of the buffer caused an issue with comma delimitation
when th first element of an array or map was discarded (from not meeting
predicate requirements), leading to an extra comma and therefore an
invalid JSON output.
By saving the value of the "previous" variable when buffering begins, we
can restore the variables value when discarding the buffered content.

See #3235
parent 7f76b6cc
......@@ -164,11 +164,14 @@ class VidjilParser(object):
bufferOn = any(prefix == item[0] or prefix == item[0]+'.item' for item in self.prefixes)
if bufferOn and event == "start_map":
saved_previous = previous
res += writer.write(prefix, event, value, previous)
previous = event
if bufferOn and event == "end_map":
if not self._writer.conserveBuffer:
previous = saved_previous
res += self._writer.endBuffering()
previous = event
return res
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment