cJSON
cJSON copied to clipboard
cJSON_Print generates invalid JSOn when locale uses comma as decimal point
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?