Skip to content

cJSON_CreateFloatArray output error #537

Open
@Eaglewzw

Description

@Eaglewzw

hey,Dav,i got a trouble in this program
here i want to store the values of AF array in cJSON
but when i used cJSON_CreateFloatArray(aF, 2)
the output result is not the original data(0.01 0.15)
how should i solve it?

#include <stdio.h>
#include "cJSON.h"

#include <stdio.h>
#include "cJSON.h"

int main(void)
{
cJSON *iRoot = NULL;
float aF[2] = {0.01, 0.15};
iRoot = cJSON_CreateObject();
cJSON_AddItemToObject(iRoot, "aF", cJSON_CreateFloatArray(aF, 2));
printf("%s \n", cJSON_Print(iRoot));
cJSON_Delete(iRoot);
}
#include <stdio.h>
#include "cJSON.h"

Output:
{
"aF": [0.00999999977648258, 0.15000000596046448]
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions