正常字符串的string.format是没问题的但是在拼接json的字符串的时候因为里面包含了 {}  花括号 里面又嵌套了 {0} {1} {2}这些要替换的关键字 所以会报错。

经过百度。

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

  string strTemplate = "{{\"C0061_Code\":\"{0}\",\"C0061_Name\":\"{1}\",\"C0010_SCode\":\"{2}\",\"C0010_SName\":\"{3}\",\"Type\":\"{4}\"}},";//
  sb1.AppendFormat(strTemplate, row["C0061_Code"].ToString(), row["C0061_Name"].ToString(), row["C0010_SCode"].ToString(), row["C0010_SName"].ToString(),row["C0061_Type"].ToString());

 

相关文章:

  • 2021-06-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2021-10-13
  • 2022-12-23
相关资源
相似解决方案