Commit 50ac211a authored by Ryan Herbert's avatar Ryan Herbert

vidjilparser.py 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 40322233
......@@ -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
self._writer.startBuffering()
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
Markdown is supported
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