Fixes #5761.
This commit is contained in:
parent
427aa2d395
commit
d1daccac2f
2 changed files with 38 additions and 5 deletions
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue