Fix MaxDepth when used with ToObject inside of a JsonConverter (#2505)

This commit is contained in:
James Newton-King
2021-03-31 15:57:25 +13:00
committed by GitHub
parent ae9fe44e13
commit f7e7bd05d9
11 changed files with 287 additions and 6 deletions
@@ -36,6 +36,7 @@ using System.Runtime.Serialization.Json;
#endif
using System.Text;
using System.Threading;
using Newtonsoft.Json.Linq;
#if DNXCORE50
using Xunit;
using Assert = Newtonsoft.Json.Tests.XUnitAssert;
@@ -306,6 +307,21 @@ namespace Newtonsoft.Json.Tests
{
return @"@""" + json.Replace(@"""", @"""""") + @"""";
}
protected string GetNestedJson(int depth)
{
JObject root = new JObject();
JObject current = root;
for (int i = 0; i < depth - 1; i++)
{
JObject nested = new JObject();
current[i.ToString()] = nested;
current = nested;
}
return root.ToString();
}
}
public static class CustomAssert