Support for tuples
This commit is contained in:
parent
a0607c6375
commit
f4bd22e054
|
@ -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:
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
Loading…
Reference in New Issue