nevermindzzt / cson Goto Github PK
View Code? Open in Web Editor NEW基于C语言的json数据映射解析库
License: MIT License
基于C语言的json数据映射解析库
License: MIT License
项目中遇到客户使用json字段不规范,”level-position“不能作为结构体元素名称,所以无法在不修改cson源码的基础上使用cson。
我的修改是:增加以下类似的宏定义即可使用
/**
使用:CSON_MODEL_INT2(MQTTSubTopicOrientationRecvPayload_s, level_position, "level-position"),
在使用demo工程的时候,遇到以下几个问题:
1.64位系统因指针占8个字节导致地址错位,可以加以说明
2.csonFree函数释放CSON_TYPE_LIST类型时,如果是csonIsBasicListModel类型,应为*tmpNode = (int)((p->obj)); ,而不是 *tmpNode = (int)(&(p->obj));
3.csonEncode函数在csonEncodeObject时,csonEncodeString直接使用了现有的地址,没有新分配地址
导致cJSON_Delete(json);时,会释放不是本次申请的地址,导致运行时出错malloc(): memory corruption (fast):
首先感谢分享代码,json中的bool类型无法解析正确,每次都是0,不管数据是true还是false。
cson.c文件中的第630行tmpNode = (int)(&(p->obj));,应改为tmpNode = (int)(p->obj);
struct test
{
char id;
short num;
int max;
double value;
char *name;
struct subtest sub[10];<--------------------!!!
CsonList *list;
char *str[2];
CsonList *charList;
CsonList *strList;
};
如果支持了,可能我要没研究透。
很好用,支持作者,但是有点问题,映射地址的时候没考虑64位系统😂,还有一些地方有bug,你有国内邮箱么,我发给你我修改之后的对比报告,我这儿不方便推送分支给你
比如:服务器下发命令的json最多支持3个命令,例如:
{
"pir_enable": true,
"led_enable": false,
"wifi_enable": true;
}
但是有的时候可能只发送,其中两种,或者只发送一种:
例如:
{
"pir_enable": true,
"led_enable": false,
}
或者
{
"led_enable": false,
"wifi_enable": true;
}
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.