cJSON icon indicating copy to clipboard operation
cJSON copied to clipboard

cJSON_Print generates invalid JSOn when locale uses comma as decimal point

Open GregoryVV opened this issue 1 year ago • 0 comments

When the json data contains a non-integer floating point value, cJSON_Print will generate invalid json when the locale is such that the decimal point is a comma.

I've discovered this issue because some (yet to be determined) library changes the locale for number formatting (which is set to "C" on application startup) to something else (where the decimal point character is a comma). I can work around it by calling setlocale( LC_NUMERIC, "C") before invoking cJSON_Print but maybe it's not a bad idea to modify print_number to use a point regardless of the current locale?

GregoryVV avatar Aug 03 '22 12:08 GregoryVV