From 2ed47eba81fd83c9ae4d94e2d31218a95f2440ed Mon Sep 17 00:00:00 2001 From: Arnaud Date: Thu, 16 Apr 2026 10:03:19 +0400 Subject: [PATCH] Remove logs with generics --- serde/json/deserializer.nim | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/serde/json/deserializer.nim b/serde/json/deserializer.nim index c8da8b3..7746144 100644 --- a/serde/json/deserializer.nim +++ b/serde/json/deserializer.nim @@ -198,56 +198,41 @@ proc fromJson*[T: ref object or object](_: type T, json: JsonNode): ?!T = else: res ): - logScope: - field = $T & "." & name - mode - let hasDeserializePragma = value.hasCustomPragma(deserialize) let opts = getSerdeFieldOptions(deserialize, name, value) let isOptionalValue = typeof(value) is Option var skip = false # workaround for 'continue' not supported in a 'fields' loop - # logScope moved into proc due to chronicles issue: https://github.com/status-im/nim-chronicles/issues/148 - logScope: - topics = "serde json deserialization" - case mode of Strict: if opts.key notin json: return failure newSerdeError("object field missing in json: " & opts.key) elif opts.ignore: # unable to figure out a way to make this a compile time check - warn "object field marked as 'ignore' while in Strict mode, field will be deserialized anyway" + discard of OptIn: if not hasDeserializePragma: - trace "object field not marked as 'deserialize', skipping" skip = true elif opts.ignore: - trace "object field marked as 'ignore', skipping" skip = true elif opts.key notin json and not isOptionalValue: return failure newSerdeError("object field missing in json: " & opts.key) of OptOut: if opts.ignore: - trace "object field is opted out of deserialization ('ignore' is set), skipping" skip = true elif hasDeserializePragma and opts.key == name: - warn "object field marked as deserialize in OptOut mode, but 'ignore' not set, field will be deserialized" + discard if not skip: if isOptionalValue: let jsonVal = json{opts.key} without parsed =? typeof(value).fromJson(jsonVal), e: - trace "failed to deserialize field", - `type` = $typeof(value), json = jsonVal, error = e.msg return failure(e) value = parsed # not Option[T] elif opts.key in json and jsonVal =? json{opts.key}.catch and not jsonVal.isNil: without parsed =? typeof(value).fromJson(jsonVal), e: - trace "failed to deserialize field", - `type` = $typeof(value), json = jsonVal, error = e.msg return failure(e) value = parsed