Skip to content
Snippets Groups Projects
Commit 14b5edb1 authored by Jakob Olsson's avatar Jakob Olsson
Browse files

lib_commons.*: some fixes to get_object_by_keys

parent 80ba4060
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ size_t write_func(void *buffer, size_t size, size_t nmemb, void *data) ...@@ -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 *get_object_by_keys(struct json_object *input_obj, char *input_key, char *output_key)
{ {
struct json_object *obj = NULL; struct json_object *obj = NULL;
struct json_object *jstring = NULL; struct json_object *jstring;
enum json_type type; enum json_type type;
type = json_object_get_type(input_obj); 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 ...@@ -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) { json_object_object_foreach(input_obj, key, val) {
if (strcmp(input_key, key) != 0) if (strcmp(input_key, key) != 0)
goto fail; continue;
obj = json_object_new_object(); 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; break;
} }
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <json-c/json.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. * Struct used for parsing the curl response from the dongle.
...@@ -25,5 +28,5 @@ struct string { ...@@ -25,5 +28,5 @@ struct string {
*/ */
size_t write_func(void *buffer, size_t size, size_t nmemb, void *data); 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 #endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment