Skip to content

Instantly share code, notes, and snippets.

@lexruee
Created October 10, 2017 21:28
Show Gist options
  • Save lexruee/dcca061d2c9888a57bf3b5e5c63dbf4f to your computer and use it in GitHub Desktop.
Save lexruee/dcca061d2c9888a57bf3b5e5c63dbf4f to your computer and use it in GitHub Desktop.
Reading json files with gjs
{
"key": "value"
}
#!/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