62 instantiations of JsonResult
ApiExplorerWebSite (1)
ApiExplorerDataFilter.cs (1)
46context.Result = new JsonResult(descriptions);
BasicWebSite (16)
Areas\Area1\Controllers\RemoteAttribute_VerifyController.cs (1)
17return new JsonResult(value: false);
Areas\Area2\Controllers\RemoteAttribute_VerifyController.cs (1)
18return new JsonResult(value: string.Format(
Controllers\ActionConstraints\ConsumesAttribute_OveridesController.cs (1)
16return new JsonResult(product);
Controllers\ContentNegotiation\ContentNegotiationController.cs (1)
13return new JsonResult("Index Method");
Controllers\ContentNegotiation\ProducesJsonController.cs (1)
13return new JsonResult(new { MethodName = "Produces_WithNonObjectResult" });
Controllers\JsonResultWithNewtonsoftJsonController.cs (5)
23return new JsonResult(new { Message = "hello" }); 28var result = new JsonResult(new { Message = "hello" }); 35return new JsonResult(new { Message = "hello" }, _customSerializerSettings); 40return new JsonResult(null); 45return new JsonResult("hello");
Controllers\JsonResultWithSystemTextJsonController.cs (5)
20return new JsonResult(new { Message = "hello" }); 25var result = new JsonResult(new { Message = "hello" }); 32return new JsonResult(new { Message = "hello" }, _customSerializerSettings); 37return new JsonResult(null); 42return new JsonResult("hello");
Controllers\RemoteAttribute_VerifyController.cs (1)
39return new JsonResult($"/RemoteAttribute_Verify/IsIdAvailable rejects {name}: '{value}'.");
Microsoft.AspNetCore.Mvc.Core.Test (21)
Infrastructure\JsonResultExecutorTestBase.cs (20)
30var result = new JsonResult(new { foo = "abcd" }); 50var result = new JsonResult(new { foo = "abcd" }); 72var result = new JsonResult(new { foo = "abcd" }) 95var result = new JsonResult(new { foo = "abcd" }); 115var result = new JsonResult(new { foo = "abcd" }); 141var result = new JsonResult(new { foo = "abcd" }); 166var result = new JsonResult(new { foo = "abcd" }); 190var result = new JsonResult(new { foo = "abcd" }, serializerSettings); 209var result = new JsonResult(new ModelWithSerializationError()); 240var result = new JsonResult("result_value"); 258var result = new JsonResult(null); 283var result = new JsonResult(model); 299var result = new JsonResult(new { foo = "abcd" }, new object()); 316var result = new JsonResult(value: null); 334var result = new JsonResult(TestAsyncEnumerable()); 352var result = new JsonResult(TestAsyncPrimitiveEnumerable()); 369var result = new JsonResult(AsyncEnumerableClosedConnection()); 400var result = new JsonResult(AsyncEnumerableClosedConnection()) 434var result = new JsonResult(AsyncEnumerableThrows()); 454var result = new JsonResult(AsyncEnumerableThrows());
Infrastructure\SystemTextJsonResultExecutorTest.cs (1)
26var result = new JsonResult(new ThrowingFormatterModel())
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (22)
JsonResultTest.cs (1)
28var result = new JsonResult(value);
NewtonsoftJsonResultExecutorTest.cs (1)
40var result = new JsonResult(TestAsyncEnumerable());
src\Mvc\Mvc.Core\test\Infrastructure\JsonResultExecutorTestBase.cs (20)
30var result = new JsonResult(new { foo = "abcd" }); 50var result = new JsonResult(new { foo = "abcd" }); 72var result = new JsonResult(new { foo = "abcd" }) 95var result = new JsonResult(new { foo = "abcd" }); 115var result = new JsonResult(new { foo = "abcd" }); 141var result = new JsonResult(new { foo = "abcd" }); 166var result = new JsonResult(new { foo = "abcd" }); 190var result = new JsonResult(new { foo = "abcd" }, serializerSettings); 209var result = new JsonResult(new ModelWithSerializationError()); 240var result = new JsonResult("result_value"); 258var result = new JsonResult(null); 283var result = new JsonResult(model); 299var result = new JsonResult(new { foo = "abcd" }, new object()); 316var result = new JsonResult(value: null); 334var result = new JsonResult(TestAsyncEnumerable()); 352var result = new JsonResult(TestAsyncPrimitiveEnumerable()); 369var result = new JsonResult(AsyncEnumerableClosedConnection()); 400var result = new JsonResult(AsyncEnumerableClosedConnection()) 434var result = new JsonResult(AsyncEnumerableThrows()); 454var result = new JsonResult(AsyncEnumerableThrows());
Microsoft.AspNetCore.Mvc.ViewFeatures (2)
Controller.cs (2)
291return new JsonResult(data); 314return new JsonResult(data, serializerSettings);
103 references to JsonResult
BasicWebSite (12)
Controllers\JsonResultWithNewtonsoftJsonController.cs (6)
21public JsonResult Plain() 26public JsonResult CustomContentType() 28var result = new JsonResult(new { Message = "hello" }); 33public JsonResult CustomSerializerSettings() 38public JsonResult Null() 43public JsonResult String()
Controllers\JsonResultWithSystemTextJsonController.cs (6)
18public JsonResult Plain() 23public JsonResult CustomContentType() 25var result = new JsonResult(new { Message = "hello" }); 30public JsonResult CustomSerializerSettings() 35public JsonResult Null() 40public JsonResult String()
Microsoft.AspNetCore.Mvc.ApiExplorer.Test (3)
DefaultApiDescriptionProviderTest.cs (3)
2366private JsonResult ReturnsJsonResult() 2391private Task<JsonResult> ReturnsTaskOfJsonResult() 2416private ValueTask<JsonResult> ReturnsValueTaskOfJsonResult()
Microsoft.AspNetCore.Mvc.Core (9)
DependencyInjection\MvcCoreServiceCollectionExtensions.cs (1)
246services.TryAddSingleton<IActionResultExecutor<JsonResult>, SystemTextJsonResultExecutor>();
Infrastructure\SystemTextJsonResultExecutor.cs (5)
16internal sealed partial class SystemTextJsonResultExecutor : IActionResultExecutor<JsonResult> 34public async Task ExecuteAsync(ActionContext context, JsonResult result) 109private JsonSerializerOptions GetSerializerOptions(JsonResult result) 121nameof(JsonResult), 122nameof(JsonResult.SerializerSettings),
JsonResult.cs (3)
16/// Creates a new <see cref="JsonResult"/> with the given <paramref name="value"/>. 25/// Creates a new <see cref="JsonResult"/> with the given <paramref name="value"/>. 75var executor = services.GetRequiredService<IActionResultExecutor<JsonResult>>();
Microsoft.AspNetCore.Mvc.Core.Test (24)
Infrastructure\JsonResultExecutorTestBase.cs (22)
30var result = new JsonResult(new { foo = "abcd" }); 50var result = new JsonResult(new { foo = "abcd" }); 72var result = new JsonResult(new { foo = "abcd" }) 95var result = new JsonResult(new { foo = "abcd" }); 115var result = new JsonResult(new { foo = "abcd" }); 141var result = new JsonResult(new { foo = "abcd" }); 166var result = new JsonResult(new { foo = "abcd" }); 190var result = new JsonResult(new { foo = "abcd" }, serializerSettings); 209var result = new JsonResult(new ModelWithSerializationError()); 240var result = new JsonResult("result_value"); 258var result = new JsonResult(null); 283var result = new JsonResult(model); 299var result = new JsonResult(new { foo = "abcd" }, new object()); 316var result = new JsonResult(value: null); 334var result = new JsonResult(TestAsyncEnumerable()); 352var result = new JsonResult(TestAsyncPrimitiveEnumerable()); 369var result = new JsonResult(AsyncEnumerableClosedConnection()); 400var result = new JsonResult(AsyncEnumerableClosedConnection()) 434var result = new JsonResult(AsyncEnumerableThrows()); 454var result = new JsonResult(AsyncEnumerableThrows()); 474protected IActionResultExecutor<JsonResult> CreateExecutor() => CreateExecutor(NullLoggerFactory.Instance); 476protected abstract IActionResultExecutor<JsonResult> CreateExecutor(ILoggerFactory loggerFactory);
Infrastructure\SystemTextJsonResultExecutorTest.cs (2)
13protected override IActionResultExecutor<JsonResult> CreateExecutor(ILoggerFactory loggerFactory) 26var result = new JsonResult(new ThrowingFormatterModel())
Microsoft.AspNetCore.Mvc.Formatters.Json (1)
Properties\AssemblyInfo.cs (1)
7[assembly: TypeForwardedTo(typeof(JsonResult))]
Microsoft.AspNetCore.Mvc.NewtonsoftJson (11)
DependencyInjection\NewtonsoftJsonMvcCoreBuilderExtensions.cs (3)
65f.ServiceType == typeof(IActionResultExecutor<JsonResult>) && 66f.ImplementationType?.Assembly == typeof(JsonResult).Assembly); 72services.TryAddSingleton<IActionResultExecutor<JsonResult>, NewtonsoftJsonResultExecutor>();
NewtonsoftJsonResultExecutor.cs (8)
18/// Executes a <see cref="JsonResult"/> to write to the response. 20internal sealed partial class NewtonsoftJsonResultExecutor : IActionResultExecutor<JsonResult> 63/// Executes the <see cref="JsonResult"/> and writes the response. 66/// <param name="result">The <see cref="JsonResult"/>.</param> 68public async Task ExecuteAsync(ActionContext context, JsonResult result) 145private JsonSerializerSettings GetSerializerSettings(JsonResult result) 157nameof(JsonResult), 158nameof(JsonResult.SerializerSettings),
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (28)
DependencyInjection\NewtonsoftJsonMvcCoreBuilderExtensionsTest.cs (2)
68.AddSingleton<IActionResultExecutor<JsonResult>, SystemTextJsonResultExecutor>(); 74var jsonResultExecutor = Assert.Single(services, d => d.ServiceType == typeof(IActionResultExecutor<JsonResult>));
JsonResultTest.cs (2)
28var result = new JsonResult(value); 52services.AddSingleton<IActionResultExecutor<JsonResult>>(executor);
NewtonsoftJsonResultExecutorTest.cs (2)
16protected override IActionResultExecutor<JsonResult> CreateExecutor(ILoggerFactory loggerFactory) 40var result = new JsonResult(TestAsyncEnumerable());
src\Mvc\Mvc.Core\test\Infrastructure\JsonResultExecutorTestBase.cs (22)
30var result = new JsonResult(new { foo = "abcd" }); 50var result = new JsonResult(new { foo = "abcd" }); 72var result = new JsonResult(new { foo = "abcd" }) 95var result = new JsonResult(new { foo = "abcd" }); 115var result = new JsonResult(new { foo = "abcd" }); 141var result = new JsonResult(new { foo = "abcd" }); 166var result = new JsonResult(new { foo = "abcd" }); 190var result = new JsonResult(new { foo = "abcd" }, serializerSettings); 209var result = new JsonResult(new ModelWithSerializationError()); 240var result = new JsonResult("result_value"); 258var result = new JsonResult(null); 283var result = new JsonResult(model); 299var result = new JsonResult(new { foo = "abcd" }, new object()); 316var result = new JsonResult(value: null); 334var result = new JsonResult(TestAsyncEnumerable()); 352var result = new JsonResult(TestAsyncPrimitiveEnumerable()); 369var result = new JsonResult(AsyncEnumerableClosedConnection()); 400var result = new JsonResult(AsyncEnumerableClosedConnection()) 434var result = new JsonResult(AsyncEnumerableThrows()); 454var result = new JsonResult(AsyncEnumerableThrows()); 474protected IActionResultExecutor<JsonResult> CreateExecutor() => CreateExecutor(NullLoggerFactory.Instance); 476protected abstract IActionResultExecutor<JsonResult> CreateExecutor(ILoggerFactory loggerFactory);
Microsoft.AspNetCore.Mvc.ViewFeatures (6)
Controller.cs (6)
282/// Creates a <see cref="JsonResult"/> object that serializes the specified <paramref name="data"/> object 286/// <returns>The created <see cref="JsonResult"/> that serializes the specified <paramref name="data"/> 289public virtual JsonResult Json(object? data) 295/// Creates a <see cref="JsonResult"/> object that serializes the specified <paramref name="data"/> object 307/// <returns>The created <see cref="JsonResult"/> that serializes the specified <paramref name="data"/> 312public virtual JsonResult Json(object? data, object? serializerSettings)
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (9)
ControllerTest.cs (4)
316var actualJsonResult = controller.Json(data); 319Assert.IsType<JsonResult>(actualJsonResult); 332var actualJsonResult = controller.Json(data, serializerSettings); 335Assert.IsType<JsonResult>(actualJsonResult);
ControllerUnitTestabilityTests.cs (5)
200var jsonResult = Assert.IsType<JsonResult>(result); 214jsonResult = Assert.IsType<JsonResult>(result); 232var jsonResult = Assert.IsType<JsonResult>(result);