From d08e578c5600af3c23f8b6751bac3c1bb7c8cabb Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Thu, 26 Sep 2024 14:13:23 +0200 Subject: [PATCH] allow serializing distinct arrays 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