mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-01 11:39:01 +08:00
29 lines
580 B
GLSL
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"))
|