使用Newtonsoft.Json,报以上错误,问题的原因是有"",把“”替换成null:

以前的json:

[{"WengvNj":"df5c38c6dd1744c59605da1fc85a0500","WengvSgtm":"2019-12-16 修理合同","WengvSu":"2019TJR001LX","WengvYewm":"修理","WengvXzhbdc":"1","WengvSuam":"","WengvXonvmkeq":"2019/12/16 0:00:00","WengvKosqjvp":"GK","WengvHapl":"SVH30","WengvWgaqoijz":"Y","WengvWgaqoiyags":"OK,同意!","WengvWgaqoixma":"wecrew","WengvWgaqoiomgs":"2019/12/16 10:20:10","WengvUrhvmkeqfhphk":"2019/12/16 0:00:00","WengvFyrbjuppnht":"2020/2/13 0:00:00","WengvWkhtrdjpnhtikskn":"2019/12/16 0:00:00","WengvWkhtrdjfnyttrlx":"","WengvJslz":"0","WengvYxhvbzzdg":"1","WengvUgfunxeoba":"","WengvUgfunxeyrh":"0","WengvUgfunxeegoikj":"","WengvJdjpjxrq":"","WengvHayznxnk":"CNY","WengvUgfunxeeha":"","WengvXat":"4400","WengvFmlvli":"LMF","WengvYxhlndjbr":"EXW","WengvXvlkrkwzbht":"","WengvHxlicoxma":"wecrew","WengvHxlicoomgs":"2019/12/16 10:19:46","WengvQgzbmkeq":"","WengvAgsqm":"","WengvTxkmanlfr":"","WengvFoyuxnp":"","WengvGafma":"","WengvGafmazsaas":"","WengvGafmaoxmvz":"","WengvAkulxb":"","WengvAkulxbtzicxsvswx":"","WengvAkulxbdtvdptu":"","WengvAkulxblpq":"","WengvAkulxbwuaybqe":"","WengvAkulxbwuayexffx":"","WengvAkulxbwuaytcrae":"","WengvGafmavtzxapd":"","WengvGafmavtzxdweew":"","WengvGafmavtzxsbqzd":"","WengvGafmamzzswgc":"","WengvGafmakabeckui":"","WengvGafmamzzswgcusmy":"","WengvAkulxbnaatxhd":"","WengvAkulxbdutbieiq":"","WengvAkulxbnaatxhdvtnz":"","WengvHuubaknfgmeu":"","WengvXkulyoamvfptu":"","WengvXkulyoamvfayec":"","WengvXkulyoamvfayecibjjb":"","WengvWkwirbxmaost":"","WengvWkwirbxmazxdb":"","WengvWkwirbxmazxdbhaiia":"","WengvXkulyoamvfhyxfmimu":"","WengvXkulyoamvfhyxfmimuayse":"","WengvWkwirbdutbieiq":"","WengvWkwirbdutbieiqwuoa":""}]

  解决方案:

        public string RemoveJsonFieldIsNull(string str)
{
if (string.IsNullOrEmpty(str)) return str;
string reg=":\"\"";
str = ReplaceByRegex(reg, str, ":null"); return str; //string reg = "(?<beginStr>[^\"]*?)(?<key>\"?We*?\"?:?)(?<value>\".*?\",*)(?<endStr>[^\"]*?)";
//string strSrcReg = "(?<beginSrc>^.*?(?=images))(?<char>(images))(?<endSrc>(?<=images).*?$)";
// string reg = "(?<beginStr>^.*?)(?=:\"\")(?<value>(:\"\"))(?<endStr>(?<=:\"\").*?$)";
//string reg = "(?<beginStr>^.*?)(?<value>(:\"\"))(?<endStr>.*?$)";
//return ReplaceByRegex(reg, str, match =>
//{
// string beginStr = match.Groups["beginStr"].Value;
// string value = match.Groups["value"].Value;
// string endStr = match.Groups["endStr"].Value;
// return beginStr+ ":null"+ endStr;
//});
}
public static string ReplaceByRegex(string strReg, string html, string target)
{
return ReplaceByRegex(strReg, html, m => target);
}
public static string ReplaceByRegex(string strReg, string html, MatchEvaluator function)
{
if (string.IsNullOrEmpty(html) || string.IsNullOrEmpty(strReg)) return null; Regex regex = new Regex(strReg, RegexOptions.Singleline | RegexOptions.IgnoreCase); html = regex.Replace(html, function);
return html;
}

  

//去掉为json中value为null的key
var jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };

  处理后的json:

[{"WengvNj":"df5c38c6dd1744c59605da1fc85a0500","WengvSgtm":"2019-12-16 修理合同","WengvSu":"2019TJR001LX","WengvYewm":"修理","WengvXzhbdc":"1","WengvSuam":null,"WengvXonvmkeq":"2019/12/16 0:00:00","WengvKosqjvp":"GK","WengvHapl":"SVH30","WengvWgaqoijz":"Y","WengvWgaqoiyags":"OK,同意!","WengvWgaqoixma":"wecrew","WengvWgaqoiomgs":"2019/12/16 10:20:10","WengvUrhvmkeqfhphk":"2019/12/16 0:00:00","WengvFyrbjuppnht":"2020/2/13 0:00:00","WengvWkhtrdjpnhtikskn":"2019/12/16 0:00:00","WengvWkhtrdjfnyttrlx":null,"WengvJslz":"0","WengvYxhvbzzdg":"1","WengvUgfunxeoba":null,"WengvUgfunxeyrh":"0","WengvUgfunxeegoikj":null,"WengvJdjpjxrq":null,"WengvHayznxnk":"CNY","WengvUgfunxeeha":null,"WengvXat":"4400","WengvFmlvli":"LMF","WengvYxhlndjbr":"EXW","WengvXvlkrkwzbht":null,"WengvHxlicoxma":"wecrew","WengvHxlicoomgs":"2019/12/16 10:19:46","WengvQgzbmkeq":null,"WengvAgsqm":null,"WengvTxkmanlfr":null,"WengvFoyuxnp":null,"WengvGafma":null,"WengvGafmazsaas":null,"WengvGafmaoxmvz":null,"WengvAkulxb":null,"WengvAkulxbtzicxsvswx":null,"WengvAkulxbdtvdptu":null,"WengvAkulxblpq":null,"WengvAkulxbwuaybqe":null,"WengvAkulxbwuayexffx":null,"WengvAkulxbwuaytcrae":null,"WengvGafmavtzxapd":null,"WengvGafmavtzxdweew":null,"WengvGafmavtzxsbqzd":null,"WengvGafmamzzswgc":null,"WengvGafmakabeckui":null,"WengvGafmamzzswgcusmy":null,"WengvAkulxbnaatxhd":null,"WengvAkulxbdutbieiq":null,"WengvAkulxbnaatxhdvtnz":null,"WengvHuubaknfgmeu":null,"WengvXkulyoamvfptu":null,"WengvXkulyoamvfayec":null,"WengvXkulyoamvfayecibjjb":null,"WengvWkwirbxmaost":null,"WengvWkwirbxmazxdb":null,"WengvWkwirbxmazxdbhaiia":null,"WengvXkulyoamvfhyxfmimu":null,"WengvXkulyoamvfhyxfmimuayse":null,"WengvWkwirbdutbieiq":null,"WengvWkwirbdutbieiqwuoa":null}]

  

C# Newtonsoft.Json.JsonReaderException:“Could not convert string to decimal:的更多相关文章

  1. .Net使用Newtonsoft.Json.dll(JSON.NET)对象序列化成json、反序列化json示例教程

    JSON作为一种轻量级的数据交换格式,简单灵活,被很多系统用来数据交互,作为一名.NET开发人员,JSON.NET无疑是最好的序列化框架,支持XML和JSON序列化,高性能,免费开源,支持LINQ查询 ...

  2. Newtonsoft.Json 用法

    Newtonsoft.Json 是.NET 下开源的json格式序列号和反序列化的类库.官方网站: http://json.codeplex.com/ 使用方法 1.首先下载你需要的版本,然后在应用程 ...

  3. 屌丝技能--转Json(Newtonsoft.Json.dll)

    妈妈再也不用为我转Json而担忧了!! 很简单,没什么好说明的,嗯! public class ShowTablePage<T> where T : class, new() { publ ...

  4. c# 使用 Newtonsoft.Json 序列化json字符串以及,反序列化对象

    1. 序列化 对象 /** 使用 Newtonsoft.Json 序列化对象 **/ [WebMethod] public String getPersonInfos() { // 初始化数据 Lis ...

  5. 问题:c# newtonsoft.json使用;结果:Newtonsoft.Json 用法

    Newtonsoft.Json 用法 Newtonsoft.Json 是.NET 下开源的json格式序列号和反序列化的类库.官方网站: http://json.codeplex.com/ 使用方法 ...

  6. .NET Core 3.0 System.Text.Json 和 Newtonsoft.Json 行为不一致问题及解决办法

    行为不一致 .NET Core 3.0 新出了个内置的 JSON 库, 全名叫做尼古拉斯 System.Text.Json - 性能更高占用内存更少这都不是事... 对我来说, 很多或大或小的项目能少 ...

  7. Net Core 下 Newtonsoft.Json 转换字符串 null 替换成string.Empty

    原文:Net Core 下 Newtonsoft.Json 转换字符串 null 替换成string.Empty public class NullToEmptyStringResolver : De ...

  8. .NET中的Newtonsoft.Json.JsonConvert.SerializeObject(string a)

    1.將string a 序列化為Json格式: 2.使用條件:將Newtonsoft.Json.dll作為引用添加到項目中.下载地址在这:http://json.codeplex.com/

  9. Newtonsoft.Json C# Json序列化和反序列化工具的使用、类型方法大全 C# 算法题系列(二) 各位相加、整数反转、回文数、罗马数字转整数 C# 算法题系列(一) 两数之和、无重复字符的最长子串 DateTime Tips c#发送邮件,可发送多个附件 MVC图片上传详解

    Newtonsoft.Json C# Json序列化和反序列化工具的使用.类型方法大全   Newtonsoft.Json Newtonsoft.Json 是.Net平台操作Json的工具,他的介绍就 ...

随机推荐

  1. vuejs的导航栏固定

    https://blog.csdn.net/wang1006008051/article/details/78003974 博主文章,超级详细,上面传送们 不过博主的导航栏跳动比较明显,我自己做了修复 ...

  2. 分分钟搞定Redis编译安装

    1.  依赖包安装 yum -y install cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc make gcc- ...

  3. OpenStack Train版 简单部署流程

    environment 1.网络平面 management(管理网络)→软件安装,组件通信 provider(提供实例网络)→:提供者网络:直接获取ip地址,实例之间直接互通   自服务网络(私有网络 ...

  4. MAC盗版软件下载网站黑名单

    上面有大量的开源软件或者免费软件,拒绝盗版从我做起, 下面被删除的网站提供大量破解软件下载,欢迎大家监督它们. 玩转苹果:http://www.ifunmac.com Mac软件下载站:http:// ...

  5. Scala比较器---Ordered与Ordering

    1.Ordered 和 Ordering Scala提供两个特质(trait)Ordered与Ordering用于比较.其中,Ordered混入(mix)Java的Comparable接口,而Orde ...

  6. JavaGC垃圾回收机制和常见垃圾回收算法

    Java GC是在什么时候,对什么东西,做了什么事情?” 什么位置:大部分在堆中,还有方法区!!方法区的垃圾收集主要回收两部分内容:废弃常量和无用的类,当满了之后同样触发FullGC, HotSpot ...

  7. linux (08) nginx入门详解

    一. nginx 入门 nginx 入门学习 web服务器软件 windows IIS服务器 linux nginx apache 收费​lighthttp 公司的技术栈 收费版技术栈 apache ...

  8. 【OI备忘录】dalao博文收藏夹

    [dalao学习笔记总览] [数学] 数论分块:数论分块 矩阵树定理Matrix_Tree:矩阵树Matrix-Tree定理与行列式 杨氏矩阵:杨氏矩阵和钩子公式 Hall定理:Hall定理学习小记 ...

  9. 201871010136 -赵艳强《面向对象程序设计(java)》第十六周学习总结

    201871010136-赵艳强<面向对象程序设计(java)>第十六周学习总结   项目 内容 这个作业属于哪个课程 <任课教师博客主页链接>https://www.cnbl ...

  10. Access-Control-Allow-Origin 响应一个携带身份信息(Credential)的HTTP请求时,必需指定具体的域,不能用通配符

    https://www.cnblogs.com/raind/p/10771778.html Access-Control-Allow-Origin.HTTP响应头,指定服务器端允许进行跨域资源访问的来 ...