This commit is contained in:
Dominik Picheta 2017-05-17 16:11:26 +01:00
commit d1daccac2f
2 changed files with 38 additions and 5 deletions

View file

@ -226,4 +226,24 @@ when isMainModule:
let x = parseJson("""{ "field": 5}""")
let data = to(x, FooBar)
doAssert data.field == 5.0
doAssert data.field == 5.0
block:
type
BirdColor = object
name: string
rgb: array[3, float]
type
Bird = object
age: int
height: float
name: string
colors: array[2, BirdColor]
var red = BirdColor(name: "red", rgb: [1.0, 0.0, 0.0])
var blue = Birdcolor(name: "blue", rgb: [0.0, 0.0, 1.0])
var b = Bird(age: 3, height: 1.734, name: "bardo", colors: [red, blue])
let jnode = %b
let data = jnode.to(Bird)
doAssert data == b