Last active
April 4, 2018 17:39
-
-
Save nathandaly/acde3469c2260317b212ad6cc37d0d73 to your computer and use it in GitHub Desktop.
Parse JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(" ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"demo": { | |
"PORT": 3001 | |
}, | |
"chat": { | |
"PORT": 3002 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment