lib/json-write-stream/yielding.rb in json-write-stream-1.0.2 vs lib/json-write-stream/yielding.rb in json-write-stream-1.1.0
- old
+ new
@@ -58,28 +58,31 @@
class YieldingObjectWriter < YieldingWriter
def after_initialize
stream.write('{')
end
- def write_array(key)
+ def write_array(key, before = '')
write_comma
+ stream.write(before)
increment
write_key(key)
stream.write(':')
super(true)
end
- def write_object(key)
+ def write_object(key, before = '')
write_comma
+ stream.write(before)
increment
write_key(key)
stream.write(':')
super(true)
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
@@ -97,11 +100,12 @@
class YieldingArrayWriter < YieldingWriter
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
def close