且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C# String.Format格式化json字符串中包含"{" "}"报错问题

更新时间:2022-06-08 15:04:32

json.Append(String.Format("{\"total\":{0},\"row\":{1}}", lineCount, strJSON));直接会报错

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

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