Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cJSON_False is true #509

Open
zloyvolkey opened this issue Sep 18, 2020 · 1 comment
Open

cJSON_False is true #509

zloyvolkey opened this issue Sep 18, 2020 · 1 comment

Comments

@zloyvolkey
Copy link

#include <stdio.h>
#include "cjson/cJSON.h"
void main()
{
    cJSON *test = cJSON_CreateObject();
    cJSON_AddBoolToObject(test, "test_bool", cJSON_False);
    printf("%s", cJSON_Print(test));
    return;
}

output:
❯ ./a.out { "test_bool": true }%

is this ok?

@Alanscut
Copy link
Collaborator

I have to say this is a misleading function... you should pass 0 or 1 to create cJSON_False or cJSON_True, because cJSON_False and cJSON_True is the type of JSON object, and false(0) and true(1) are values of object.
so you should write as below:

cJSON_AddBoolToObject(test, "test_bool", 0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants