C# 取Json字典值替换并补充特殊符号
作者:互联网
定义一个可变字符字符串StringBuilder 并实例化:
StringBuilder buffer = new StringBuilder();
处理键值,在字符串之间补充特殊符号:
//dit 实例化的字典,存储临时参数
if (!(dit == null || dit.Count == 0))
{
int i = 0;
foreach (string key in dit.Keys)
{
if (i > 0)
{
buffer.AppendFormat("&{0}={1}", key, dit[key]);
}
else
{
buffer.AppendFormat("{0}={1}", key, dit[key]);
i++;
}
}
}
这里补充的是&符号,结果如下:
{partner_code=WZPY&InnerItemName=&wight=0.51&express_no=75418746635778&accept_province=&accept_city=&accept_dist=&accept_address=&accept_tel=&accept_name=&post_name=&post_tel=&post_province=&post_city=&post_dist=&post_address=&source_country=142&scan_user_no=3213001234&scan_type=2&scan_time=2020/12/7 10:44:08&own_net_no=&partner_key=FD6C7AB4A92E4A8CA79645C742E978FD}
标签:scan,C#,accept,buffer,Json,key,dit,post,特殊符号 来源: https://blog.csdn.net/qq_42782011/article/details/110795513