我正在尝试转换s := '{"selector:"{"Status":"open"}"}'为 type string,因为我需要将此作为参数传递给使用GetQueryResult().
我试过UnescapeString了,它只接受字符串作为参数:
fmt.Println("args " ,html.UnescapeString(s)
但是s是一个 Go rune。
使用string原始文字反引号,而不是rune文字单引号。
例如,
package main
import (
"fmt"
)
func main() {
s := `{"selector:"{"Status":"open"}"}`
fmt.Printf("type %T: %s", s, s)
}
游乐场: https: //play.golang.org/p/lGARb35VHTv
输出:
type string: {"selector:"{"Status":"open"}"}