dgrove-oss commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r942839017


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, 
key string, childKey st
        return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) 
interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
        var res interface{}
 
-       for key, value := range response {
-               if key == field {
-                       res = value
-                       break
+       if result, ok := response.(map[string]interface{}); ok {
+               for key, value := range result {
+                       if key == field {
+                               res = value
+                               break
+                       }
                }
        }
-
+       if result, ok := response.([]interface{}); ok {

Review Comment:
   Should we insist that `field` be "" if response is an array?  I'm not sure 
exactly how this function is used, but it might be error prone to just silently 
return the array result when the caller asked for a specific field of what they 
must have been expecting to be a JSON object.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to