fix ACLK protocol version always parsed as 0 (#9502)

This commit is contained in:
Timotej S 2020-07-08 16:20:47 +02:00 committed by GitHub
parent 628598c4d5
commit 11e4ac1357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -133,7 +133,7 @@ int cloud_to_agent_parse(JSON_ENTRY *e)
break;
case JSON_NUMBER:
if (!strcmp(e->name, "version")) {
data->version = atoi(e->original_string);
data->version = e->data.number;
break;
}
break;

View File

@ -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);
}
}