Fixes #5856. Code based on @loloiccl's PR (#5879).

This commit is contained in:
Dominik Picheta
2017-11-28 21:49:34 +00:00
committed by Dominik Picheta
parent 216119212c
commit 11fcae5705
2 changed files with 37 additions and 6 deletions

View File

@@ -246,4 +246,17 @@ when isMainModule:
var b = Bird(age: 3, height: 1.734, name: "bardo", colors: [red, blue])
let jnode = %b
let data = jnode.to(Bird)
doAssert data == b
doAssert data == b
block:
type
MsgBase = ref object of RootObj
name*: string
MsgChallenge = ref object of MsgBase
challenge*: string
let data = %*{"name": "foo", "challenge": "bar"}
let msg = data.to(MsgChallenge)
doAssert msg.name == "foo"
doAssert msg.challenge == "bar"