在Asp.net Core 3.1中,可以通过修改JsonOptions类的MaxDepth和MaxJsonLength属性来设置JSON对象的最大深度和最大长度。具体代码示例如下:
//在Startup.cs的ConfigureServices方法中添加以下代码 services.AddMvc() .AddJsonOptions(options => { options.JsonSerializerOptions.MaxDepth = 256; //设置最大深度 options.JsonSerializerOptions.MaxJsonLength = 2147483647; //设置最大长度 });