JSON使用MaxDepth反序列化设置最大深度
2015-12-11 15:01
453 查看
1.当反序列化时,使用MaxDepth指定最大深度,本例最大深度实际是3,但指定为2.即抛出异常.
2.运行的结果
JSON源代码下载地址:http://download.csdn.net/detail/lovegonghui/9342751
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using GongHuiNewtonsoft.Json; using GongHuiNewtonsoft.Json.Serialization; using GongHuiNewtonsoft.Json.Converters; namespace JSONDemo { class Program { static void Main(string[] args) { try { JsonConvert.DeserializeObject<List<IList<IList<string>>>>(@"[ [ [ '3', 'Three', 'III' ] ] ]", new JsonSerializerSettings { MaxDepth = 2 //MaxDepth=3 }); } catch (JsonReaderException ex) { Console.WriteLine(ex.Message); } } } }
2.运行的结果
JSON源代码下载地址:http://download.csdn.net/detail/lovegonghui/9342751
相关文章推荐
- 【03】json使用
- 10008---JavaScript--事件
- 【02】json语法
- js 技术关于 ajax 的跨域问题
- Javascript变长参数和默认参数
- 【01】JSON基本信息
- JSON使用Error反序列化忽略非法日期
- js判断接入设备
- js时间格式转换
- 10007---JavaScript--函数
- js里获取表单输入值进行比对的方法
- js---SM
- JSON使用TraceWriter反序列化获取调试日志
- ExtJs4 笔记(5) Ext.Button 按钮
- JSON使用IContractResolver序列化实现属性名骆驼命名法
- js中的document.write
- 百宝云Json与数组命令教程
- 10006---JavaScript--对象
- JSON使用TypeNameHandling序列化与反序列化.NET类型和声明类型
- JS替换非正则替换