1.当反序列化时,使用MaxDepth指定最大深度,本例最大深度实际是3,但指定为2.即抛出异常.
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
});