c# string.format json字符串 formatException错误
正常字符串的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());
c# string.format json字符串 formatException错误的更多相关文章
- 【转载】 C#使用String.Format拼接字符串
在C#程序开发过程中,很多时候会使用字符串拼接,最简单的字符串拼接操作就是所有的字符串使用加号+相加连接起来,但这种代码形式非常不适合代码维护阅读,尤其是拼接字符串语句比较复杂的时候,如拼接SQL语句 ...
- C# string.Format json格式字符串报错”输入字符串的格式不正确“
当我们在string.Format中传入Json字符串时,会报”输入字符串的格式不正确“,这是因为json的"{"符号的问题,最开始我是想着用转义一下"{",但 ...
- string.format格式化字符串中转义大括号“{}”
今天,用Java读取配置文件占位符,使用String.Format(string format,object arg0)方法.以前只知“{0}”为索引占位符(即格式项),与参数列表中的第一个对象相对应 ...
- String.format() 格式化字符串
1.几种常见的转换符 转换符 说明 实例 %d 整数类型(十进制) 99 %f 浮点类型 99.99 %s 字符串类型 "mingrisoft" %c 字符类型 'm' %b 布尔 ...
- 【转换】Bean、List、Map、Array、String与JSON字符串的相互转换
import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.math.BigDecimal; i ...
- string类(三、string.format格式字符串)
参考连接: http://www.cnblogs.com/luluping/archive/2009/04/30/1446665.html http://blog.csdn.net/samsone/a ...
- java 对象转JSON字符串 $ref 错误
顾名思义,这个是对象转Json时,发生的引用错误. 比较简单的方法是: 使用 帮助方法 https://www.cnblogs.com/hanjun0612/p/9779781.html Conver ...
- Map<String,String>转换json字符串
import java.util.HashMap; import java.util.Map; import net.sf.json.JSONObject; public class testJson ...
- fastjson string[]转 json字符串
@RequestMapping(value = "/friendlink_list/province_list", produces = {"application/js ...
随机推荐
- Velocity(9)——宏
定义宏和使用宏 #macro指令用于定义一个VTL模板的重复代码块——宏.下面是一个简单的定义宏的例子: #macro( d ) <tr><td></td>< ...
- Leetcode: Nested List Weight Sum II
Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...
- PHP获取毫秒时间戳,利用microtime()函数
PHP获取毫秒时间戳,利用microtime()函数 php本身没有提供返回毫秒数的函数,但提供了一个microtime()函数,借助此函数,可以很容易定义一个返回毫秒数的函数.php的毫秒是没有默认 ...
- Css Study - 纵向Menu - By html and Css
http://www.wikihow.com/Create-a-Dropdown-Menu-in-HTML-and-CSS HTML <div id="leftmenu"&g ...
- 如何清理photoshop cs6 被升级的烦人的adobe creative cloud组件
安装photoshop cs6(虽然目前已经退出到cc 2015,不过因激活成熟度等,我还是偏向于使用cs6,够用!),默认安装adobe application manager. 不过如果不小心单独 ...
- 模板引擎:ArtTemplate 使用入门和简单的使用
下载地址:https://github.com/aui/artTemplate 快速上手请参考:https://github.com/aui/artTemplate 通过阅读artTemplate原文 ...
- [Python]实现XMPP协议即时通讯发送消息功能
#-*- coding: utf-8 -*- __author__ = 'tsbc' import xmpp import time #注意帐号信息,必须加@域名格式 from_user = 'che ...
- print函数
python中print既可以写成print a,也可以写成print(a) >>> a=1 >>> print a 1 >>> print(a) ...
- 浏览器URL编码
jsp页面中通过请求另一个页面并通过url传递了带有中文的参数,结果在接收端获取参数时乱码了 经检查乱码现象指出新在IE浏览器中,其他浏览器火狐.chrome等不会有问题 最后的解决方式是: 手动将此 ...
- centos6.6编译安装lnmp系列之PHP
简介: 环境:虚拟机+centos6.6 在百度云盘里面我分享的安装软件包,包含LNMP系列软件. http://pan.baidu.com/s/1gdvnimv 1.安装前配置: 关闭selinux ...