From 11e4ac13577ebe65b24e7b2a7bd594ae5e128539 Mon Sep 17 00:00:00 2001 From: Timotej S <6674623+underhood@users.noreply.github.com> Date: Wed, 8 Jul 2020 16:20:47 +0200 Subject: fix ACLK protocol version always parsed as 0 (#9502) --- libnetdata/json/json.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libnetdata') diff --git a/libnetdata/json/json.c b/libnetdata/json/json.c index d2407ba405..bd164aeffc 100644 --- a/libnetdata/json/json.c +++ b/libnetdata/json/json.c @@ -161,6 +161,16 @@ static inline void json_jsonc_set_boolean(JSON_ENTRY *e,int value) { e->data.boolean = value; } +static inline void json_jsonc_set_integer(JSON_ENTRY *e, char *key, int64_t value) { + size_t len = strlen(key); + if(len > JSON_NAME_LEN) + len = JSON_NAME_LEN; + e->type = JSON_NUMBER; + memcpy(e->name, key, len); + e->name[len] = 0; + e->data.number = value; +} + /** * Parse Array * @@ -449,6 +459,9 @@ size_t json_walk(json_object *t, void *callback_data, int (*callback_function)(s } else if (type == json_type_boolean) { json_jsonc_set_boolean(&e,json_object_get_boolean(val)); callback_function(&e); + } else if (type == json_type_int) { + json_jsonc_set_integer(&e,key,json_object_get_int64(val)); + callback_function(&e); } } -- cgit v1.2.3