调用newtonsoft.json反序列出错
来源:互联网 发布:淘宝商家管理系统 编辑:程序博客网 时间:2024/06/05 18:59
调用newtonsoft.json反序列出错:
Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[WebService.Yeesky.JsonString]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.Path 'S', line 1, position 5.
贴一片E文solution:
JsonConvert.DeserializeObject - Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[System.String]'Run into this issue while consuming a 3rd party JSON API using JSON.NET.Complete exception message:Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[System.String]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.The json string I was trying to deserialize had a field looking like this:"extras": {},In my C# class that field was declared as a List<string>. By declaring the field as an IDictionary<string, string> instead the problem was solved. Lesson learned: If the json value is '[]' => declare the field as List<type> If the json value is '{}' => declare the field IDictionary<type, type>
阅读全文
1 0
- 调用newtonsoft.json反序列出错
- Newtonsoft.Json 反序列化JSON数组
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json序列化和反序列
- Newtonsoft.Json.dll 反序列化JSON字符串
- Newtonsoft.Json 使用 C#序列号json,反序列化对象
- Newtonsoft.Json.dll 反序列化JSON字符串 .
- mvc使用Newtonsoft.Json反序列化json数据
- 分布式任务调度平台XXL-JOB
- 网银支付接口编程资料汇总
- 【ASP】连接Access数据库的登陆系统
- MVC3+Spring.net+NHibernate+ExtJs的简单架构
- XMLHTTP中setRequestHeader方法和参数
- 调用newtonsoft.json反序列出错
- .net(c#)提取多层嵌套的JSON
- Js 正则表达式匹配字符串中是否含有中文
- [转帖]VS选中某个代码报错修补
- 模拟实现memset,memcpy,memmove函数
- SQL存储过程的调用及写法
- 服务器重启后网站可以打开,一会网站就打不开
- SQL 2008 windows登录失败,错误18456, 更正
- 关于vs调试正确。但是发布到iis就出现无法访问后天局面