Open oneonce opened 4 years ago
typedef struct cJSON { struct cJSON next, prev; struct cJSON child; int type; char valuestring; int valueint; double valuedouble; char *string; } cJSON;
size_t size = sizeof(cJSON) = 40
typedef struct cJSON { struct cJSON next, prev; struct cJSON child; int type; char string; union Value { char *valuestring; //int valueint; // can not save 0xFFFF FFFF FFFF FFFF int64_t valuelong; // can save 0xFFFF FFFF FFFF FFFF double valuedouble; } value; } cJSON;
size_t size = sizeof(cJSON) = 32
when we use cJSON for embedded device(such as: ARM Cortex M3/M4/M7), the memory is very small.
cJSON has plans to use union in the future(milestone 2.0.0), for details, please see #63. But int64_t is incompatible with c89, it may not be acceptable in the short term.
https://github.com/zserge/jsmn
typedef struct cJSON { struct cJSON next, prev; struct cJSON child; int type; char valuestring; int valueint; double valuedouble; char *string; } cJSON;
size_t size = sizeof(cJSON) = 40
typedef struct cJSON { struct cJSON next, prev; struct cJSON child; int type; char string; union Value { char *valuestring; //int valueint; // can not save 0xFFFF FFFF FFFF FFFF int64_t valuelong; // can save 0xFFFF FFFF FFFF FFFF double valuedouble; } value; } cJSON;
size_t size = sizeof(cJSON) = 32
when we use cJSON for embedded device(such as: ARM Cortex M3/M4/M7), the memory is very small.