1 Star 9 Fork 2

linuxmail/lib-zjson

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
array_test.cpp 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
linuxmail 提交于 2024-01-17 22:09 +08:00 . 增加 int
/*
* ================================
* eli960@qq.com
* http://linuxmail.cn/
* 2017-08-23
* ================================
*/
#include "zcc_json.h"
int main(int argc, char **argv)
{
zcc::json js, *tmpjs;
do {
/* 准备 js */
js.array_add(1)->array_add(false)->array_add("333")->array_push(555);
/* 得到 [ 1, false, "333", 555 ] */
js.debug_show();
} while (0);
do {
/* 在最前面插入 "begin" 和 second */
js.array_unshift("begin")->array_insert(1, "second");
/* 得到 [ "begin", "second", 1, false, "333", 555 ] */
js.debug_show();
} while (0);
do {
/* 删除最后两个节点 */
js.array_pop(0);
js.array_delete(-1, 0);
/* 删除第 2 个节点 */
js.array_delete(1, 0);
/* 得到 [ "begin", 1, false ] */
js.debug_show();
} while (0);
do {
/* 在第 6 个 节点 添加 2.0 */
js.array_update(5, 2.0);
/* 得到 [ "begin", 1, false, null, null, 2.0 ] */
js.debug_show();
} while (0);
while (js.array_pop(&tmpjs)) {
/* 弹出第一个节点 */
if (tmpjs) {
delete tmpjs;
}
js.debug_show();
}
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/linuxmail/lib-zjson.git
git@gitee.com:linuxmail/lib-zjson.git
linuxmail
lib-zjson
lib-zjson
master

搜索帮助