|
|
3 mēneši atpakaļ | |
|---|---|---|
| .. | ||
| json_app.lua | 3 mēneši atpakaļ | |
| main.lua | 3 mēneši atpakaļ | |
| readme.md | 3 mēneši atpakaļ | |
1、main.lua:主程序入口;
2、json_app.lua:json 序列化与反序列化功能模块;
使用 Air780EPM 核心板搭配 json 库演示 json 序列化与反序列化功能;
演示分为两部分:
1、将 Lua 对象 转为 JSON 字符串:
示例一:Lua string 转为 JSON string;
示例二:Lua number 转为 JSON string;
示例三:Lua boolean 转为 JSON string;
示例四:Lua table 转为 JSON string;
示例五:Lua nil 转为 JSON string;
序列化失败示例和指定浮点数示例;
2、将 JSON 字符串 转为 Lua 对象:
1、Air780EPM 核心板一块
2、TYPE-C USB数据线一根
2、Air780EPM V2016 版本(理论上最新版本固件也可以,如果使用最新版本的固件不可以,可以烧录 V2016-1 固件对比验证)
1、搭建好硬件环境
2、Luatools 工具烧录内核固件和 demo 脚本代码
3、烧录成功后,自动开机运行
4、正常运行情况时的日志如下:
[00000001.009] I/user.string_string_test1 序列化成功: "test"
[00000001.009] I/user.number_string_test1 序列化成功: 123456789
[00000001.010] I/user.boolean_string_test1 序列化成功: true
[00000001.010] I/user.table_string_test1 序列化成功: {"abc":123,"ttt":true,"def":"123"}
[00000001.010] I/user.nil_string_test1 序列化成功:
[00000001.011] I/user.table_string_test2 序列化失败: Cannot serialise function: type not supported
[00000001.011] I/user.table_string_test3 序列化成功: {"abc":1234.568}
[00000001.011] I/user.string_string_test1 反序列化成功: test
[00000001.011] I/user.string_number_test1 反序列化成功: 123456789
[00000001.011] I/user.string_boolean_test1 反序列化成功: true
[00000001.011] I/user.string_table_test1.2 反序列化成功: table: 01FE5010
[00000001.011] I/user.string_table_test1.2 反序列化成功: 1234545
[00000001.011] I/user.string_table_test2 反序列化失败: Expected value but found T_OBJ_END at character 8
[00000001.012] I/user.table_string_test3 序列化成功: {"abc":{}}
[00000001.012] I/user.json 序列化成功: {"str":"ABC\r\nDEF\r\n"}
[00000001.012] I/user.json 反序列化成功: ABC
DEF
true
[00000001.012] I/user.json.null {"name":null}
[00000001.012] I/user.json.null true
[00000001.012] I/user.json.null false