allow serializing distinct arrays (#97)

A complement to
https://github.com/status-im/nim-json-serialization/pull/93
This commit is contained in:
Jacek Sieka 2024-09-26 16:19:22 +02:00 committed by GitHub
parent 8b51cd8bc9
commit b83739b430
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -365,8 +365,12 @@ proc writeValue*(w: var JsonWriter, value: auto) {.gcsafe, raises: [IOError].} =
# to avoid the allocation here:
append $value
elif value is (seq or array or openArray):
w.writeArray(value)
elif value is (seq or array or openArray) or
(value is distinct and distinctBase(value) is (seq or array or openArray)):
when value is distinct:
w.writeArray(distinctBase value)
else:
w.writeArray(value)
elif value is (distinct or object or tuple):
mixin flavorUsesAutomaticObjectSerialization