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



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

字符串中包含{或者},則需要用{{ 來代替字符 {,用}} 代替 }

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


原文鏈接: