C#中String.Format格式化json中包含"{" "}"報(bào)錯(cuò)問(wèn)題解決



json.Append(String.Format("{\"total\":{0},\"col\":{1}}", Count, strJSON));直接會(huì)報(bào)錯(cuò)

字符串中包含{或者},則需要用{{ 來(lái)代替字符 {,用}} 代替 }

如:json.Append(String.Format("{{\"total\":{0},\"col\":{1}}}", Count, strJSON));


原文鏈接: