Skip to content

cJSON floating point issue #4

@flo90

Description

@flo90

Hi,
i tried your code today and its working very well but cJSON is not converting a float number correctly.
You hit the problem if you try to read the dht22. The output looks like this:
{
"temp": %.0f,
"hum": %.0f
}
My current fix is to typecast the values like this:
cJSON_AddNumberToObject(root,"temp",(int8_t)data.dht22.temp);
cJSON_AddNumberToObject(root,"hum",(uint8_t)data.dht22.hum);
Maybe someone know how to fix the cJSON lib easily?!

I am using the esp-open-sdk (espressif lib v1.0.1) to compile the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions