(content []string, keyValueFormat bool)
| 93 | } |
| 94 | |
| 95 | func 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 | |
| 125 | func getKeyValueFormattedJSON(data map[string]interface{}) whisk.KeyValueArr { |
| 126 | var keyValueArr whisk.KeyValueArr |
no test coverage detected