awtk/tests/fscripts/demo_ubjson.fs
2022-08-23 11:21:48 +08:00

29 lines
580 B
GLSL

//create a json
var a=json_load('
{
"name":"fscript",
"age":100
}
')
assert(object_get(a, "name")=="fscript")
assert(object_get(a, "age")==100)
//save as ubjson
var b=ubjson_save(a)
print(b)
//load from buffer
a = ubjson_load(b)
assert(object_get(a, "name")=="fscript")
assert(object_get(a, "age")==100)
//load from file as binary
assert(file_write("test.ubjson", b))
a = ubjson_load(file_read_binary("test.ubjson"))
assert(file_remove("test.ubjson"))
assert(object_get(a, "name")=="fscript")
assert(object_get(a, "age")==100)
assert(file_remove("test.ubjson"))