2022-12-10 05:06:01 +01:00
|
|
|
function json_load(path) {
|
2022-12-12 09:08:03 +01:00
|
|
|
if(!file_exists(path)) return noone;
|
2022-12-10 05:06:01 +01:00
|
|
|
|
|
|
|
var f = file_text_open_read(path);
|
|
|
|
var s = file_text_read_all(f);
|
|
|
|
file_text_close(f);
|
|
|
|
|
|
|
|
var js = json_decode(s);
|
|
|
|
return js;
|
|
|
|
}
|
|
|
|
|
|
|
|
function json_save(path, struct) {
|
|
|
|
var s = json_encode(struct);
|
|
|
|
|
|
|
|
var f = file_text_open_write(path);
|
|
|
|
file_text_write_string(f, s);
|
|
|
|
file_text_close(f);
|
2022-12-12 09:08:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function file_text_read_all(file) {
|
|
|
|
var s = "";
|
|
|
|
while(!file_text_eof(file))
|
|
|
|
s += file_text_readln(file);
|
|
|
|
return s;
|
2022-12-10 05:06:01 +01:00
|
|
|
}
|