Reputation: 1325
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 %*
Upvotes: 3
Views: 159
Reputation: 1598
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"}
Upvotes: 8