From b83739b4304b1cde05ad7470dd5faa1341cffb2e Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Thu, 26 Sep 2024 16:19:22 +0200 Subject: [PATCH] allow serializing distinct arrays (#97) A complement to https://github.com/status-im/nim-json-serialization/pull/93 --- json_serialization/writer.nim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/json_serialization/writer.nim b/json_serialization/writer.nim index 4606287..522a5bf 100644 --- a/json_serialization/writer.nim +++ b/json_serialization/writer.nim @@ -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