toptions.nim 259 B

12345678910111213141516
  1. discard """
  2. output: '''{"foo":{"test":"123"}}'''
  3. """
  4. import json, options
  5. type
  6. Foo = ref object
  7. test: string
  8. Test = object
  9. foo: Option[Foo]
  10. let js = """{"foo": {"test": "123"}}"""
  11. let parsed = parseJson(js)
  12. let a = parsed.to(Test)
  13. echo $(%*a)