diff --git a/src/artwork.c b/src/artwork.c index 81624185..b8ddf6e1 100644 --- a/src/artwork.c +++ b/src/artwork.c @@ -840,7 +840,7 @@ response_jparse_discogs(char **artwork_url, json_object *response, int max_w, in else key = "cover_image"; - image = JPARSE_DRILLDOWN(response, "results", key); + image = JPARSE_SELECT(response, "results", key); if (!image || json_object_get_type(image) != json_type_string) return ONLINE_SOURCE_PARSE_NOT_FOUND; @@ -859,7 +859,7 @@ response_jparse_musicbrainz(char **artwork_url, json_object *response, int max_w json_object *id; const char *s; - id = JPARSE_DRILLDOWN(response, "release-groups", "id"); + id = JPARSE_SELECT(response, "release-groups", "id"); if (!id || json_object_get_type(id) != json_type_string) return ONLINE_SOURCE_PARSE_NOT_FOUND; @@ -888,7 +888,7 @@ response_jparse_spotify(char **artwork_url, json_object *response, int max_w, in int image_count; int i; - images = JPARSE_DRILLDOWN(response, "albums", "items", "images"); + images = JPARSE_SELECT(response, "albums", "items", "images"); if (!images || json_object_get_type(images) != json_type_array) return ONLINE_SOURCE_PARSE_INVALID; diff --git a/src/misc_json.c b/src/misc_json.c index 9968a215..a335e560 100644 --- a/src/misc_json.c +++ b/src/misc_json.c @@ -33,11 +33,12 @@ #include "logger.h" json_object * -jparse_drilldown(json_object *haystack, const char *keys[]) +jparse_select(json_object *haystack, const char *keys[]) { json_object *needle; json_bool found; + needle = NULL; while (*keys) { found = json_object_object_get_ex(haystack, *keys, &needle); diff --git a/src/misc_json.h b/src/misc_json.h index 05a5a880..cd55d80b 100644 --- a/src/misc_json.h +++ b/src/misc_json.h @@ -35,10 +35,10 @@ // Convenience macro so that instead of calling jparse with an array of keys // to follow, you can call JPARSE_DRILLDOWN(haystack, "key1", "key2"...) -#define JPARSE_DRILLDOWN(haystack, ...) jparse_drilldown(haystack, (const char *[]){__VA_ARGS__, NULL}) +#define JPARSE_SELECT(haystack, ...) jparse_select(haystack, (const char *[]){__VA_ARGS__, NULL}) json_object * -jparse_drilldown(json_object *haystack, const char *keys[]); +jparse_select(json_object *haystack, const char *keys[]); void jparse_free(json_object *haystack);