cJSON
cJSON copied to clipboard
print: support float pretty print
Code below:
float a = 0.00001; cJSON *root = cJSON_CreateObject(); cJSON_AddNumberToObject(root, "a", a); printf("%s\n", cJSON_Print(root));
Maybe it will print: { "a": 9.9999997473787516e-06 }
But that's not what we really want, we want this: { "a": 1e-5 }
Signed-off-by: dubaowei [email protected]
This looks pretty similar to https://github.com/DaveGamble/cJSON/pull/558
Yes, it's same in a way. But I only format the 'float' type, and it could be normal when object is 'integer' Besides that, I don't add any element to basic struct cJSON, keep it small but exquisite