Add writer.stepwiseArrayCreation
This commit is contained in:
parent
b9af0be99d
commit
cc5038e0e2
|
@ -103,9 +103,7 @@ template endRecordField*(w: var JsonWriter) =
|
||||||
endRecord(w)
|
endRecord(w)
|
||||||
w.state = AfterField
|
w.state = AfterField
|
||||||
|
|
||||||
proc writeIterable*(w: var JsonWriter, collection: auto) =
|
iterator stepwiseArrayCreation*[C](w: var JsonWriter, collection: C): auto =
|
||||||
mixin writeValue
|
|
||||||
|
|
||||||
append '['
|
append '['
|
||||||
|
|
||||||
if w.hasPrettyOutput:
|
if w.hasPrettyOutput:
|
||||||
|
@ -122,7 +120,7 @@ proc writeIterable*(w: var JsonWriter, collection: auto) =
|
||||||
indent()
|
indent()
|
||||||
|
|
||||||
w.state = RecordExpected
|
w.state = RecordExpected
|
||||||
w.writeValue(e)
|
yield e
|
||||||
first = false
|
first = false
|
||||||
|
|
||||||
if w.hasPrettyOutput:
|
if w.hasPrettyOutput:
|
||||||
|
@ -132,6 +130,11 @@ proc writeIterable*(w: var JsonWriter, collection: auto) =
|
||||||
|
|
||||||
append ']'
|
append ']'
|
||||||
|
|
||||||
|
proc writeIterable*(w: var JsonWriter, collection: auto) =
|
||||||
|
mixin writeValue
|
||||||
|
for e in w.stepwiseArrayCreation(collection):
|
||||||
|
w.writeValue(e)
|
||||||
|
|
||||||
proc writeArray*[T](w: var JsonWriter, elements: openArray[T]) =
|
proc writeArray*[T](w: var JsonWriter, elements: openArray[T]) =
|
||||||
writeIterable(w, elements)
|
writeIterable(w, elements)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue