Skip to content

Instantly share code, notes, and snippets.

@nathandaly
Last active April 4, 2018 17:39
Show Gist options
  • Save nathandaly/acde3469c2260317b212ad6cc37d0d73 to your computer and use it in GitHub Desktop.
Save nathandaly/acde3469c2260317b212ad6cc37d0d73 to your computer and use it in GitHub Desktop.
Parse JSON
import json, tables, osproc, strutils
type Services = JsonNode
proc readConfig(): Services =
result = parseFile("services.json")
when isMainModule:
var services: Services = readConfig()
for serviceName, serviceNode in services.getFields():
echo serviceName
for envName, envValue in serviceNode.getFields():
echo envName, " ", envValue
let runCmd: array[3, string] = ["docker run -it", "ubuntu", "/bin/bash"]
let _ = execCmd(runCmd.join(" "))
{
"demo": {
"PORT": 3001
},
"chat": {
"PORT": 3002
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment