-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Open
Milestone
Description
Hello!
Just an idea:
Why didn't you merge the valuestring, valueint and valuedouble parameters of the cJSON structure in an union?
/* The cJSON structure: */
typedef struct cJSON
{
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *next;
struct cJSON *prev;
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
struct cJSON *child;
/* The type of the item, as above. */
int type;
union
{
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
char * s;
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
int32_t i32;
int64_t i64; /* support of #566 */
/* The item's number, if type==cJSON_Number */
double d;
} value;
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
char *string;
} cJSON;
For sure, it's not backward compatible. - However, it's reducing the size of the cJSON structure. In addition of that I prefer the access like object->value.i32.
Best regards,
NC
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels