Merge pull request #7205 from GULPF/json-to-fix

Fix `json.to` for types with generic parameters
This commit is contained in:
Dominik Picheta 2018-02-12 09:22:35 +00:00 • committed by GitHub
commit 23d272f652
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -380,4 +380,11 @@ when isMainModule:
let dataDeser = to(dataParsed, Test1)
doAssert dataDeser.a == 1
doAssert dataDeser.f == 6
doAssert dataDeser.i == 9.9'f32
doAssert dataDeser.i == 9.9'f32
# deserialize directly into a table
block:
let s = """{"a": 1, "b": 2}"""
let t = parseJson(s).to(Table[string, int])
doAssert t["a"] == 1
doAssert t["b"] == 2