From 714c3292397d62b7b3d4dabbe87686efb7acd8e5 Mon Sep 17 00:00:00 2001 From: Arnaldo Cesco Date: Tue, 12 Nov 2024 11:43:22 +0100 Subject: [PATCH] Device aliases are a map, not an array Fix the parsing of device aliases, which are to be parsed in the same way as attributes. Signed-off-by: Arnaldo Cesco --- client/appengine_data.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/appengine_data.go b/client/appengine_data.go index 08de9d2..37825c9 100644 --- a/client/appengine_data.go +++ b/client/appengine_data.go @@ -224,14 +224,14 @@ func (r ListDeviceInterfacesResponse) Raw(f func(*http.Response) any) any { } // Parses data obtained by performing a request device's aliases. -// Returns the list of aliases as an array of strings. +// Returns the list of aliases as a map strings to strings. func (r ListDeviceAliasesResponse) Parse() (any, error) { defer r.res.Body.Close() b, _ := io.ReadAll(r.res.Body) - data := gjson.GetBytes(b, "data.aliases").Array() - aliases := []string{} - for _, v := range data { - aliases = append(aliases, v.Str) + data := gjson.GetBytes(b, "data.aliases").Map() + aliases := map[string]string{} + for k, v := range data { + aliases[k] = v.Str } return aliases, nil }