2023-02-14 05:32:32 +01:00
|
|
|
function json_encode_minify(map) {
|
|
|
|
return json_minify(json_encode(map));
|
|
|
|
}
|
|
|
|
|
|
|
|
function json_stringify_minify(map) {
|
|
|
|
return json_minify(json_stringify(map));
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
function json_save(path, map) {
|
|
|
|
var s = json_encode_minify(map);
|
2022-12-10 05:06:01 +01:00
|
|
|
|
2023-01-04 02:30:04 +01:00
|
|
|
var f = file_text_open_write(path);
|
|
|
|
file_text_write_string(f, s);
|
|
|
|
file_text_close(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
function json_load_struct(path) {
|
|
|
|
if(!file_exists(path)) return noone;
|
|
|
|
|
|
|
|
var f = file_text_open_read(path);
|
|
|
|
var s = file_text_read_all(f);
|
|
|
|
file_text_close(f);
|
|
|
|
|
|
|
|
var js = json_parse(s);
|
|
|
|
return js;
|
|
|
|
}
|
|
|
|
|
|
|
|
function json_save_struct(path, struct) {
|
2023-02-14 05:32:32 +01:00
|
|
|
var s = json_stringify_minify(struct);
|
2023-01-04 02:30:04 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
var f = file_text_open_write(path);
|
|
|
|
file_text_write_string(f, s);
|
|
|
|
file_text_close(f);
|
|
|
|
}
|