mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-26 15:06:22 +01:00
45 lines
No EOL
898 B
Text
45 lines
No EOL
898 B
Text
function json_encode_minify(map) {
|
|
return json_minify(json_encode(map));
|
|
}
|
|
|
|
function json_stringify_minify(map) {
|
|
return json_minify(json_stringify(map));
|
|
}
|
|
|
|
function json_load(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_decode(s);
|
|
return js;
|
|
}
|
|
|
|
function json_save(path, map) {
|
|
var s = json_encode_minify(map);
|
|
|
|
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) {
|
|
var s = json_stringify_minify(struct);
|
|
|
|
var f = file_text_open_write(path);
|
|
file_text_write_string(f, s);
|
|
file_text_close(f);
|
|
} |