Created
October 10, 2017 21:28
-
-
Save lexruee/dcca061d2c9888a57bf3b5e5c63dbf4f to your computer and use it in GitHub Desktop.
Reading json files with gjs
This file contains hidden or 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
{ | |
"key": "value" | |
} |
This file contains hidden or 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
#!/usr/bin/env gjs | |
const GLib = imports.gi.GLib; | |
let [ok, contents] = GLib.file_get_contents('config.json'); | |
if (ok) { | |
log(contents); | |
let map = JSON.parse(contents); | |
log(map['key']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment