Import a specific macro from a module in Nim

Viewed 98

I import the json module just to use its useful %* macro:

import json        # for %*
let json_payload = $(%* {"username": "admin", "password": "1234"})

Is it possible to import just this particular macro from the module? Something like this (though obviously this doesn't work):

from json import %*
1 Answers

you can absolutely do that, but for operators you need to surround them with backticks. you are also using $ from json so you need to import that too:

from json import `%*`,`$`
let json_payload = $(%* {"username": "admin", "password": "1234"})
echo json_payload #{"username":"admin","password":"1234"}
Related