diff --git a/json_serialization/reader.nim b/json_serialization/reader.nim index fdd98b9..f6529f0 100644 --- a/json_serialization/reader.nim +++ b/json_serialization/reader.nim @@ -221,7 +221,11 @@ proc readValue*(r: var JsonReader, value: var auto) = let fields = T.fieldReadersTable(JsonReader) var expectedFieldPos = 0 while r.lexer.tok == tkString: - let reader = findFieldReader(fields[], r.lexer.strVal, expectedFieldPos) + when T is tuple: + var reader = fields[][expectedFieldPos].reader + expectedFieldPos += 1 + else: + var reader = findFieldReader(fields[], r.lexer.strVal, expectedFieldPos) r.lexer.next() r.skipToken tkColon if reader != nil: diff --git a/json_serialization/std/net.nim b/json_serialization/std/net.nim index 3750be2..de311f4 100644 --- a/json_serialization/std/net.nim +++ b/json_serialization/std/net.nim @@ -1,5 +1,9 @@ -import std/net, ../../json_serialization.nim -export net +import + std/[net, strutils], + ../../json_serialization, chronos/transports/common + +export + net, common proc writeValue*(writer: var JsonWriter, value: Port) = writeValue(writer, uint16 value) @@ -7,3 +11,9 @@ proc writeValue*(writer: var JsonWriter, value: Port) = proc readValue*(reader: var JsonReader, value: var Port) = value = Port reader.readValue(uint16) +proc writeValue*(writer: var JsonWriter, value: AddressFamily) = + writeValue(writer, $value) + +proc readValue*(reader: var JsonReader, value: var AddressFamily) = + value = parseEnum[AddressFamily](reader.readValue(string)) +