Convert a JSON string, which has extra double quotes (eg, `"thing"`) into a normal string with the extra double quotes removed (eg "thing"). Normal strings will be returned as-is. `"thing"` -> "thing" "thing" -> "thing"
(s string)
| 186 | // `"thing"` -> "thing" |
| 187 | // "thing" -> "thing" |
| 188 | func ConvertJSONString(s string) string { |
| 189 | var jsonString string |
| 190 | err := JSONUnmarshal([]byte(s), &jsonString) |
| 191 | if err != nil { |
| 192 | return s |
| 193 | } else { |
| 194 | return jsonString |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | // ConvertToJSONString takes a string, and returns a JSON string, with any illegal characters escaped. |
| 199 | func ConvertToJSONString(s string) string { |