diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-08-12 07:26:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-08-12 07:26:17 +0000 |
commit | 7877a98bd9c00db5e81dd2f8c734cba2bab20be7 (patch) | |
tree | d18b767250f7c7ced9b8abe2ece784ac1fe24d3e /libnetdata/json | |
parent | Releasing debian version 1.35.1-2. (diff) | |
download | netdata-7877a98bd9c00db5e81dd2f8c734cba2bab20be7.tar.xz netdata-7877a98bd9c00db5e81dd2f8c734cba2bab20be7.zip |
Merging upstream version 1.36.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/json')
-rw-r--r-- | libnetdata/json/json.c | 4 | ||||
-rw-r--r-- | libnetdata/json/json.h | 19 |
2 files changed, 14 insertions, 9 deletions
diff --git a/libnetdata/json/json.c b/libnetdata/json/json.c index 1f391eea..e03556b5 100644 --- a/libnetdata/json/json.c +++ b/libnetdata/json/json.c @@ -111,7 +111,7 @@ int json_callback_print(JSON_ENTRY *e) break; case JSON_NUMBER: - sprintf(txt,"%Lf", e->data.number); + sprintf(txt, NETDATA_DOUBLE_FORMAT_AUTO, e->data.number); buffer_strcat(wb,txt); break; @@ -168,7 +168,7 @@ static inline void json_jsonc_set_integer(JSON_ENTRY *e, char *key, int64_t valu e->type = JSON_NUMBER; memcpy(e->name, key, len); e->name[len] = 0; - e->data.number = value; + e->data.number = (NETDATA_DOUBLE)value; } /** diff --git a/libnetdata/json/json.h b/libnetdata/json/json.h index 79b58b17..b43f06b5 100644 --- a/libnetdata/json/json.h +++ b/libnetdata/json/json.h @@ -3,8 +3,13 @@ #if ENABLE_JSONC -# include <json-c/json.h> -#endif +#include <json-c/json.h> +// fix an older json-c bug +// https://github.com/json-c/json-c/issues/135 +#ifdef error_description +#undef error_description +#endif // error_description +#endif // ENABLE_JSONC #include "jsmn.h" @@ -26,12 +31,12 @@ typedef struct json_entry { char name[JSON_NAME_LEN + 1]; char fullname[JSON_FULLNAME_LEN + 1]; union { - char *string; // type == JSON_STRING - long double number; // type == JSON_NUMBER - int boolean; // type == JSON_BOOLEAN - size_t items; // type == JSON_ARRAY + char *string; // type == JSON_STRING + NETDATA_DOUBLE number; // type == JSON_NUMBER + int boolean; // type == JSON_BOOLEAN + size_t items; // type == JSON_ARRAY } data; - size_t pos; // the position of this item in its parent + size_t pos; // the position of this item in its parent char *original_string; |