t15835.nim 289 B

123456789101112131415161718
  1. import json
  2. type
  3. Foo = object
  4. ii*: int
  5. data*: JsonNode
  6. block:
  7. const jt = """{"ii": 123, "data": ["some", "data"]}"""
  8. let js = parseJson(jt)
  9. discard js.to(Foo)
  10. block:
  11. const jt = """{"ii": 123}"""
  12. let js = parseJson(jt)
  13. doAssertRaises(KeyError):
  14. echo js.to(Foo)