目录
一:问题
二:解决
一:问题
1:比如这是接收到的外部参数为json:{\"4\":{\"data":\"leyangjun-private/1660875949898375470-418163.jpg\"}}
2:然后使用json.Unmarshal 反序列操作,会返回:“invalid character '\\\\' looking for beginning of object key string“ 的错误
二:解决
jsonStr, jErr := strconv.Unquote("\"" + jsonStr + "\"") //直接把json字符串用Unquote处理一次即可
Unquote函数描述:
// Unquote interprets s as a single-quoted, double-quoted,
// or backquoted Go string literal, returning the string value
// that s quotes. (If s is single-quoted, it would be a Go
// character literal; Unquote returns the corresponding
// one-character string.)