From e58cb1bb74628f46fef0db914477beeb44230cd4 Mon Sep 17 00:00:00 2001 From: HeWhoWalksBehind <84110044+siriuslee69@users.noreply.github.com> Date: Sun, 8 Sep 2024 03:34:31 +0200 Subject: [PATCH] Update json.nim `%` - Conversion of an object or tuple to JsonNode doesn't work correctly for tuples atm, since the generic type is missing. Added the tuple generic type to correctly allow tuples as input as well. Credits to Elegantbeef from the Nim Discord. --- lib/pure/json.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 3d68ae5cf6556..2e8bace9fe66f 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -390,7 +390,7 @@ proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) {.inline.} = assert(obj.kind == JObject) obj.fields[key] = val -proc `%`*[T: object](o: T): JsonNode = +proc `%`*[T: object | tuple](o: T): JsonNode = ## Construct JsonNode from tuples and objects. result = newJObject() for k, v in o.fieldPairs: result[k] = %v