gitee.com/h79/goutils@v1.22.10/common/json/json_test.go (about) 1 package json 2 3 import ( 4 "encoding/json" 5 "strconv" 6 "strings" 7 "testing" 8 ) 9 10 func TestQuote(t *testing.T) { 11 var i = strconv.Quote("\"xxxx\n") 12 13 t.Log(i) 14 15 var j, _ = strconv.Unquote(i) 16 17 t.Log(j) 18 19 var jj = "{\"uid\":\"334\",\"xx\":\"deddddd\n\"}" 20 jj = strings.ReplaceAll(jj, "\n", "\\n") 21 var out = map[string]string{} 22 var _ = json.Unmarshal([]byte(jj), &out) 23 t.Log(out) 24 }