Skip to content

Commit

Permalink
Device aliases are a map, not an array
Browse files Browse the repository at this point in the history
Fix the parsing of device aliases, which
are to be parsed in the same way as attributes.

Signed-off-by: Arnaldo Cesco <arnaldo.cesco@gmail.com>
  • Loading branch information
Annopaolo committed Nov 12, 2024
1 parent a1a088d commit 714c329
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions client/appengine_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 714c329

Please sign in to comment.