mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-01 11:39:01 +08:00
33 lines
674 B
GLSL
33 lines
674 B
GLSL
//load from string
|
|
var str='{
|
|
"name" : "fscript",
|
|
"age" : 100
|
|
}'
|
|
var a=json_load(str)
|
|
|
|
assert(object_get(a, "name")=="fscript");
|
|
assert(object_get(a, "age")==100);
|
|
|
|
//save to file
|
|
var b=json_save(a)
|
|
assert(file_write("test.json", b))
|
|
|
|
//json obj to string
|
|
var c=json_save_to_string(a)
|
|
assert(c==str);
|
|
|
|
//load from file as text
|
|
a = json_load(file_read_text("test.json"))
|
|
|
|
assert(object_get(a, "name")=="fscript");
|
|
assert(object_get(a, "age")==100);
|
|
|
|
//load from file as binary
|
|
a = json_load(file_read_binary("test.json"))
|
|
assert(file_remove("test.json"))
|
|
|
|
assert(object_get(a, "name")=="fscript");
|
|
assert(object_get(a, "age")==100);
|
|
|
|
assert(file_remove("test.json"))
|