mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 15:22:11 +02:00
server: Fix invalid JSON caused by locale decimal conversion
When creating JSON data, we must ensure that our decimal numbers are converted to a string with a "." as separator, otherwise it would be an invalid JSON.
This commit is contained in:
@@ -41,9 +41,11 @@
|
||||
_JSON_AUTO_COMMA \
|
||||
g_string_append_printf (_json, "\"%s\":%" G_GUINT64_FORMAT, key, (guint64) val);
|
||||
|
||||
#define _ADD_KEY_VAL_DOUBLE(key, val) \
|
||||
#define _ADD_KEY_VAL_DOUBLE(key, val) { \
|
||||
gchar _buf[G_ASCII_DTOSTR_BUF_SIZE]; \
|
||||
_JSON_AUTO_COMMA \
|
||||
g_string_append_printf (_json, "\"%s\":%.2lf", key, (gdouble) val);
|
||||
g_string_append_printf (_json, "\"%s\":%s", key, \
|
||||
g_ascii_formatd (_buf, sizeof (_buf), "%.2f", val)); }
|
||||
|
||||
#define _ADD_KEY_VAL_STRING(key, val) \
|
||||
_JSON_AUTO_COMMA \
|
||||
|
Reference in New Issue
Block a user