diff --git a/lib_commons.c b/lib_commons.c index 57444f5403f8e79f0d3ed838acc4ff2d2f7f8710..fa93a17996c62ca972332c6131ffa2840ec03430 100644 --- a/lib_commons.c +++ b/lib_commons.c @@ -25,7 +25,7 @@ size_t write_func(void *buffer, size_t size, size_t nmemb, void *data) struct json_object *get_object_by_keys(struct json_object *input_obj, char *input_key, char *output_key) { struct json_object *obj = NULL; - struct json_object *jstring = NULL; + struct json_object *jstring; enum json_type type; type = json_object_get_type(input_obj); @@ -34,10 +34,13 @@ struct json_object *get_object_by_keys(struct json_object *input_obj, char *inpu json_object_object_foreach(input_obj, key, val) { if (strcmp(input_key, key) != 0) - goto fail; + continue; obj = json_object_new_object(); - json_object_object_add(obj, output_key, val); + jstring = json_object_new_string((char *)json_object_get_string(val)); + json_object_object_add(obj, output_key, jstring); + + //json_object_object_add(obj, output_key, val); break; } diff --git a/lib_commons.h b/lib_commons.h index 401d8435abdca3faa016bb22b39e5388790117cc..3aa05e9937bb1ba1a40573bf6c459611c1515752 100644 --- a/lib_commons.h +++ b/lib_commons.h @@ -4,6 +4,9 @@ #include <stdlib.h> #include <string.h> #include <json-c/json.h> +#define PIN_STATUS_H "PinOptState" +#define PIN_STATUS_Z "pin_status" +#define PIN_STATUS "pin_status" /** * Struct used for parsing the curl response from the dongle. @@ -25,5 +28,5 @@ struct string { */ size_t write_func(void *buffer, size_t size, size_t nmemb, void *data); -struct json_object *get_object_by_key(json_object *json_obj, char *string, char *output_key); +struct json_object *get_object_by_keys(json_object *json_obj, char *string, char *output_key); #endif \ No newline at end of file