MCPcopy Create free account
hub / github.com/apache/openwhisk-cli / getJSONFromStrings

Function getJSONFromStrings

commands/util.go:95–123  ·  view source on GitHub ↗
(content []string, keyValueFormat bool)

Source from the content-addressed store, hash-verified

93}
94
95func getJSONFromStrings(content []string, keyValueFormat bool) (interface{}, error) {
96 var data map[string]interface{}
97 var res interface{}
98
99 whisk.Debug(whisk.DbgInfo, "Convert content to JSON: %#v\n", content)
100
101 for i := 0; i < len(content); i++ {
102 dc := json.NewDecoder(strings.NewReader(content[i]))
103 dc.UseNumber()
104 if err := dc.Decode(&data); err != nil {
105 whisk.Debug(whisk.DbgError, "Invalid JSON detected for '%s' \n", content[i])
106 return whisk.KeyValueArr{}, err
107 }
108
109 whisk.Debug(whisk.DbgInfo, "Created map '%v' from '%v'\n", data, content[i])
110 }
111
112 if data == nil {
113 data = make(map[string]interface{})
114 }
115
116 if keyValueFormat {
117 res = getKeyValueFormattedJSON(data)
118 } else {
119 res = data
120 }
121
122 return res, nil
123}
124
125func getKeyValueFormattedJSON(data map[string]interface{}) whisk.KeyValueArr {
126 var keyValueArr whisk.KeyValueArr

Callers 5

package.goFile · 0.85
UpdateMethod · 0.85
UpdateExtendedVersionFunction · 0.85
getParametersFunction · 0.85
parseActionFunction · 0.85

Calls 1

getKeyValueFormattedJSONFunction · 0.85

Tested by

no test coverage detected