Unless I understand correctly, the intended behavior is that if the client passes 0, a false is created, else a true.
This is the implementation provided (reformatted for readability):
cJSON cJSON_CreateBool(int b) { cJSON item=cJSON_New_Item(); if(item)item->type=b?cJSON_True:cJSON_False; return item; }
This is the implementation it should have:
cJSON cJSON_CreateBool(int b) { cJSON item=cJSON_New_Item(); if(item)item->type=(b?cJSON_True:cJSON_False); return item; }
... it's missing the parenthesis, so it assigns b to item->type.
I apologize, I have now filed a bug for this: https://sourceforge.net/p/cjson/bugs/39/
Log in to post a comment.
Unless I understand correctly, the intended behavior is that if the client passes 0, a false is created, else a true.
This is the implementation provided (reformatted for readability):
cJSON cJSON_CreateBool(int b)
{
cJSON item=cJSON_New_Item();
if(item)item->type=b?cJSON_True:cJSON_False;
return item;
}
This is the implementation it should have:
cJSON cJSON_CreateBool(int b)
{
cJSON item=cJSON_New_Item();
if(item)item->type=(b?cJSON_True:cJSON_False);
return item;
}
... it's missing the parenthesis, so it assigns b to item->type.
I apologize, I have now filed a bug for this: https://sourceforge.net/p/cjson/bugs/39/