Why I can't unmarshal JSON with spaces in the JSON keys?

2021-03-13 Thread hronro
Why I can't unmarshal JSON with spaces in the JSON keys? import json type FooBar = object `Foo Bar`: string const jsonString = "{\"Foo Bar\": \"Hello World\"}" let foobar = to(parseJson(jsonString), FooBar) Run [Nim Playground](h

How to generate import statement in macros?

2021-03-02 Thread hronro
# main.nim import macros macro gen_import(): untyped = return newNimNode(nnkImportStmt).add infix( ident("foo"), "as", ident("bar") ) gen_import() echo bar.foobar Run # foo.nim const foobar* = "foobar"