[JSON] getBVal -> getBool; getFNum -> getFloat

This commit is contained in:
Daniil Yarancev 2017-10-13 22:43:54 +03:00
commit e29e6ec76e
5 changed files with 30 additions and 15 deletions

View file

@ -47,7 +47,7 @@ proc createLoadProc(typeName: NimIdent, identDefs: seq[NimNode]): NimNode =
`cfgIdent`.`fieldNameIdent` = `objIdent`[`fieldName`].getStr
of "int":
body.add quote do:
`cfgIdent`.`fieldNameIdent` = `objIdent`[`fieldName`].getNum().int
`cfgIdent`.`fieldNameIdent` = `objIdent`[`fieldName`].getInt().int
else:
doAssert(false, "Not Implemented")

View file

@ -87,8 +87,8 @@ when isMainModule:
result = to(node, TestVariant)
doAssert result.name == node["name"].getStr()
doAssert result.age == node["age"].getNum().uint8
doAssert result.other == node["other"].getNum()
doAssert result.age == node["age"].getInt().uint8
doAssert result.other == node["other"].getBiggestInt()
# TODO: Test object variant with set in of branch.
# TODO: Should we support heterogenous arrays?