lib/json-write-stream/stateful.rb in json-write-stream-1.0.2 vs lib/json-write-stream/stateful.rb in json-write-stream-1.1.0
- old
+ new
@@ -137,12 +137,13 @@
increment
write_key(key)
stream.write(':')
end
- def write_key_value(key, value)
+ def write_key_value(key, value, before = '')
write_comma
+ stream.write(before)
increment
write_key(key)
stream.write(":#{escape(value)}")
end
@@ -173,11 +174,12 @@
class StatefulArrayWriter < StatefulWriter
def after_initialize
stream.write('[')
end
- def write_element(element)
+ def write_element(element, before = '')
write_comma
+ stream.write(before)
increment
stream.write(escape(element))
end
# prep work