996 references to JsonSerializer
Aspire.Confluent.Kafka (1)
MetricsService.cs (1)
26statistics = JsonSerializer.Deserialize(json, StatisticsJsonSerializerContext.Default.Statistics);
Aspire.Dashboard (2)
Model\BrowserStorage\LocalBrowserStorage.cs (2)
38return new StorageResult<T>(true, JsonSerializer.Deserialize<T>(json, s_options)); 50var json = JsonSerializer.Serialize(value, s_options);
Aspire.EndToEnd.Tests (1)
tests\Shared\WorkloadTesting\ProjectInfo.cs (1)
60JsonSerializer.Deserialize<Dictionary<string, ProjectInfo>>(json)!;
Aspire.Hosting (10)
Dashboard\DashboardLifecycleHook.cs (1)
364logMessage = JsonSerializer.Deserialize(content, DashboardLogMessageContext.Default.DashboardLogMessage);
Dcp\ApplicationExecutor.cs (4)
468var serviceProducerAnnotations = JsonSerializer.Deserialize<ServiceProducerAnnotation[]>(servicesProducedAnnotationJson); 2038var current = JsonSerializer.SerializeToNode(obj); 2040var copy = JsonSerializer.Deserialize<T>(current)!; 2043var changed = JsonSerializer.SerializeToNode(copy);
Dcp\DcpDependencyCheck.cs (1)
99var dcpInfo = JsonSerializer.Deserialize<DcpInfo>(output);
Dcp\Model\ModelCommon.cs (3)
81list = JsonSerializer.Deserialize<List<TValue>>(annotationValue); 98values = JsonSerializer.Deserialize<List<TValue>>(annotationVal) ?? new(); 115var newAnnotationVal = JsonSerializer.Serialize(values);
src\Shared\LaunchProfiles\LaunchProfileExtensions.cs (1)
86var settings = JsonSerializer.Deserialize(stream, LaunchSettingsSerializerContext.Default.LaunchSettings);
Aspire.Hosting.Azure (1)
AzureBicepResource.cs (1)
160JsonSerializer.Serialize(context.Writer, inputValue);
Aspire.Hosting.Azure.Functions (1)
src\Shared\LaunchProfiles\LaunchProfileExtensions.cs (1)
86var settings = JsonSerializer.Deserialize(stream, LaunchSettingsSerializerContext.Default.LaunchSettings);
Aspire.Hosting.Testing (1)
DistributedApplicationFactory.cs (1)
217var settings = JsonSerializer.Deserialize(stream, LaunchSettingsSerializerContext.Default.LaunchSettings);
Aspire.Hosting.Tests (6)
Dashboard\DashboardLifecycleHookTests.cs (2)
142var messageJson = JsonSerializer.Serialize(message, DashboardLogMessageContext.Default.DashboardLogMessage); 169messageJson = JsonSerializer.Serialize(message, DashboardLogMessageContext.Default.DashboardLogMessage);
Dashboard\DashboardResourceTests.cs (1)
484logger.Log(logLevel, 0, JsonSerializer.Serialize(dashboardLogMessage), null, (s, _) => s);
Dcp\TestKubernetesService.cs (2)
50var serialized = JsonSerializer.Serialize(r); 51var clone = JsonSerializer.Deserialize<T>(serialized);
LaunchSettingsSerializerContextTests.cs (1)
33JsonSerializer.Deserialize(launchSettingsJson, LaunchSettingsSerializerContext.Default.LaunchSettings);
Aspire.Workload.Tests (1)
tests\Shared\WorkloadTesting\ProjectInfo.cs (1)
60JsonSerializer.Deserialize<Dictionary<string, ProjectInfo>>(json)!;
AzureSearch.ApiService (1)
Program.cs (1)
149var hotels = await JsonSerializer.DeserializeAsync<List<Hotel>>(openStream, cancellationToken: cancellationToken);
BasketService (3)
BasketService.cs (1)
87body: JsonSerializer.SerializeToUtf8Bytes(order));
Repositories\RedisBasketRepository.cs (2)
39return JsonSerializer.Deserialize<CustomerBasket>(data.ToString(), s_jsonSerializerOptions); 49var created = await _database.StringSetAsync(basket.BuyerId, JsonSerializer.Serialize(basket, s_jsonSerializerOptions));
BicepSample.ApiService (5)
Program.cs (5)
104await database.ListRightPushAsync("entries", JsonSerializer.SerializeToUtf8Bytes(entry)); 111entries.Add(JsonSerializer.Deserialize<Entry>((string)item!)!); 135entries.Add(JsonSerializer.Deserialize<Entry>(content)!); 151{ "data", JsonSerializer.Serialize(entry) } 160entries.Add(JsonSerializer.Deserialize<Entry>((string)item["data"])!);
CdkSample.ApiService (2)
Program.cs (2)
67await database.ListRightPushAsync("entries", JsonSerializer.SerializeToUtf8Bytes(entry)); 74entries.Add(JsonSerializer.Deserialize<Entry>((string)item!)!);
ConfigurationSchemaGenerator (1)
ConfigSchemaEmitter.cs (1)
48return JsonSerializer.Serialize(root, s_serializerOptions);
dotnet-user-jwts (12)
Commands\CreateCommand.cs (1)
257reporter.Output(JsonSerializer.Serialize(jwt, JwtSerializerOptions.Default));
Commands\ListCommand.cs (2)
57reporter.Output(JsonSerializer.Serialize(jwts, JwtSerializerOptions.Default)); 61reporter.Output(JsonSerializer.Serialize(Array.Empty<Jwt>(), JwtSerializerOptions.Default));
Helpers\DevJwtCliHelpers.cs (1)
144reporter.Output(JsonSerializer.Serialize(jwt, JwtSerializerOptions.Default));
Helpers\JwtAuthenticationSchemeSettings.cs (4)
19var config = JsonSerializer.Deserialize<JsonObject>(reader, JwtSerializerOptions.Default); 61JsonSerializer.Serialize(writer, config, JwtSerializerOptions.Default); 67var config = JsonSerializer.Deserialize<JsonObject>(reader, JwtSerializerOptions.Default); 77JsonSerializer.Serialize(writer, config, JwtSerializerOptions.Default);
Helpers\JwtStore.cs (2)
36Jwts = JsonSerializer.Deserialize<IDictionary<string, Jwt>>(fileStream, JwtSerializerOptions.Default) ?? new Dictionary<string, Jwt>(); 53JsonSerializer.Serialize(fileStream, Jwts);
Helpers\SigningKeysHandler.cs (2)
71secrets = JsonSerializer.Deserialize<JsonObject>(secretsFileStream, JwtSerializerOptions.Default); 96JsonSerializer.Serialize(secretsWriteStream, secrets);
InMemory.FunctionalTests (1)
EventSourceTests.cs (1)
460_logger?.LogInformation("{event}", JsonSerializer.Serialize(eventData, new JsonSerializerOptions
Microsoft.AspNetCore.Authentication.Core.Test (4)
AuthenticationPropertiesTests.cs (4)
321var json = JsonSerializer.Serialize(props); 328var deserialized = JsonSerializer.Deserialize<AuthenticationProperties>(json); 352var deserialized = JsonSerializer.Deserialize<AuthenticationProperties>(json); 376var json = JsonSerializer.Serialize(props, options);
Microsoft.AspNetCore.Authentication.JwtBearer.Tools.Tests (11)
UserJwtsTests.cs (11)
112var appSettings = JsonSerializer.Deserialize<JsonObject>(File.ReadAllText(appsettings)); 115appSettings = JsonSerializer.Deserialize<JsonObject>(File.ReadAllText(appsettings)); 156var deserialized = JsonSerializer.Deserialize<Dictionary<string, Jwt>>(output); 247var secretsJson = await JsonSerializer.DeserializeAsync<JsonObject>(openStream); 354var deserialized = JsonSerializer.Deserialize<Jwt>(output); 412var deserialized = JsonSerializer.Deserialize<Jwt>(output); 466var secretsJson = await JsonSerializer.DeserializeAsync<JsonObject>(openStream); 494var secretsJson = await JsonSerializer.DeserializeAsync<JsonObject>(openStream); 533var secretsJson = await JsonSerializer.DeserializeAsync<JsonObject>(openStream); 555var secretsJson = await JsonSerializer.DeserializeAsync<JsonObject>(openStream); 577var secretsJson = await JsonSerializer.DeserializeAsync<JsonObject>(openStream);
Microsoft.AspNetCore.Authentication.Test (1)
OAuthTests.cs (1)
536var text = JsonSerializer.Serialize(content);
Microsoft.AspNetCore.Authentication.Twitter (1)
TwitterHandler.cs (1)
371errorResponse = await JsonSerializer.DeserializeAsync(errorContentStream, TwitterJsonContext.DefaultWithOptions.TwitterErrorResponse);
Microsoft.AspNetCore.Components (2)
PersistentComponentState.cs (2)
87_currentState.Add(key, JsonSerializer.SerializeToUtf8Bytes(instance, JsonSerializerOptionsProvider.Options)); 107instance = JsonSerializer.Deserialize<TValue>(ref reader, JsonSerializerOptionsProvider.Options)!;
Microsoft.AspNetCore.Components.Endpoints (10)
Assets\ImportMapDefinition.cs (1)
208_json ??= JsonSerializer.Serialize(this, ImportMapSerializerContext.CustomEncoder.Options);
Builder\ResourceCollectionUrlEndpoint.cs (1)
100JsonSerializer.Serialize<IReadOnlyList<ResourceAsset>>(utf8Writer, resourceCollection, ResourceCollectionSerializerContext.Default.Options);
DependencyInjection\DefaultRazorComponentsServiceOptionsConfiguration.cs (1)
57var initializers = JsonSerializer.Deserialize<string[]>(options.JavaScriptInitializers);
DependencyInjection\ServerComponentSerializer.cs (1)
44var serializedServerComponentBytes = JsonSerializer.SerializeToUtf8Bytes(serverComponent, ServerComponentSerializationSettings.JsonSerializationOptions);
DependencyInjection\WebAssemblyComponentSerializer.cs (2)
19var serializedDefinitions = Convert.ToBase64String(JsonSerializer.SerializeToUtf8Bytes(definitions, WebAssemblyComponentSerializationSettings.JsonSerializationOptions)); 20var serializedValues = Convert.ToBase64String(JsonSerializer.SerializeToUtf8Bytes(values, WebAssemblyComponentSerializationSettings.JsonSerializationOptions));
Rendering\EndpointHtmlRenderer.Streaming.cs (2)
274var serializedStartRecord = JsonSerializer.Serialize(marker, ServerComponentSerializationSettings.JsonSerializationOptions); 298var serializedEndRecord = JsonSerializer.Serialize(endMarker, ServerComponentSerializationSettings.JsonSerializationOptions);
src\Shared\Components\PrerenderComponentApplicationStore.cs (2)
33var state = JsonSerializer.Deserialize( 53JsonSerializer.SerializeToUtf8Bytes(state);
Microsoft.AspNetCore.Components.Endpoints.Tests (46)
EndpointHtmlRendererTest.cs (45)
64var marker = JsonSerializer.Deserialize<ComponentMarker>(match.Groups[1].Value, ServerComponentSerializationSettings.JsonSerializationOptions); 88var preambleMarker = JsonSerializer.Deserialize<ComponentMarker>(preamble, ServerComponentSerializationSettings.JsonSerializationOptions); 98var epilogueMarker = JsonSerializer.Deserialize<ComponentMarker>(epilogue, ServerComponentSerializationSettings.JsonSerializationOptions); 130var marker = JsonSerializer.Deserialize<ComponentMarker>(match.Groups[1].Value, ServerComponentSerializationSettings.JsonSerializationOptions); 137JsonSerializer.Deserialize<ComponentParameter[]>(Convert.FromBase64String(marker.ParameterDefinitions), WebAssemblyComponentSerializationSettings.JsonSerializationOptions)); 142var value = Assert.Single(JsonSerializer.Deserialize<object[]>(Convert.FromBase64String(marker.ParameterValues), WebAssemblyComponentSerializationSettings.JsonSerializationOptions)); 167var marker = JsonSerializer.Deserialize<ComponentMarker>(match.Groups[1].Value, ServerComponentSerializationSettings.JsonSerializationOptions); 173var parameterDefinition = Assert.Single(JsonSerializer.Deserialize<ComponentParameter[]>(Convert.FromBase64String(marker.ParameterDefinitions), WebAssemblyComponentSerializationSettings.JsonSerializationOptions)); 178var value = Assert.Single(JsonSerializer.Deserialize<object[]>(Convert.FromBase64String(marker.ParameterValues), WebAssemblyComponentSerializationSettings.JsonSerializationOptions)); 203var preambleMarker = JsonSerializer.Deserialize<ComponentMarker>(preamble, ServerComponentSerializationSettings.JsonSerializationOptions); 209var parameterDefinition = Assert.Single(JsonSerializer.Deserialize<ComponentParameter[]>(Convert.FromBase64String(preambleMarker.ParameterDefinitions), WebAssemblyComponentSerializationSettings.JsonSerializationOptions)); 214var value = Assert.Single(JsonSerializer.Deserialize<object[]>(Convert.FromBase64String(preambleMarker.ParameterValues), WebAssemblyComponentSerializationSettings.JsonSerializationOptions)); 222var epilogueMarker = JsonSerializer.Deserialize<ComponentMarker>(epilogue, ServerComponentSerializationSettings.JsonSerializationOptions); 252var preambleMarker = JsonSerializer.Deserialize<ComponentMarker>(preamble, ServerComponentSerializationSettings.JsonSerializationOptions); 258var parameterDefinition = Assert.Single(JsonSerializer.Deserialize<ComponentParameter[]>(Convert.FromBase64String(preambleMarker.ParameterDefinitions), WebAssemblyComponentSerializationSettings.JsonSerializationOptions)); 263var value = Assert.Single(JsonSerializer.Deserialize<object[]>(Convert.FromBase64String(preambleMarker.ParameterValues), WebAssemblyComponentSerializationSettings.JsonSerializationOptions)); 270var epilogueMarker = JsonSerializer.Deserialize<ComponentMarker>(epilogue, ServerComponentSerializationSettings.JsonSerializationOptions); 310var marker = JsonSerializer.Deserialize<ComponentMarker>(match.Groups[1].Value, ServerComponentSerializationSettings.JsonSerializationOptions); 317var serverComponent = JsonSerializer.Deserialize<ServerComponent>(unprotectedServerComponent, ServerComponentSerializationSettings.JsonSerializationOptions); 343var preambleMarker = JsonSerializer.Deserialize<ComponentMarker>(preamble, ServerComponentSerializationSettings.JsonSerializationOptions); 350var serverComponent = JsonSerializer.Deserialize<ServerComponent>(unprotectedServerComponent, ServerComponentSerializationSettings.JsonSerializationOptions); 361var epilogueMarker = JsonSerializer.Deserialize<ComponentMarker>(epilogue, ServerComponentSerializationSettings.JsonSerializationOptions); 408var preambleMarker = JsonSerializer.Deserialize<ComponentMarker>(preamble, ServerComponentSerializationSettings.JsonSerializationOptions); 413var firstServerComponent = JsonSerializer.Deserialize<ServerComponent>(unprotectedFirstServerComponent, ServerComponentSerializationSettings.JsonSerializationOptions); 419var markerMarker = JsonSerializer.Deserialize<ComponentMarker>(marker, ServerComponentSerializationSettings.JsonSerializationOptions); 424var secondServerComponent = JsonSerializer.Deserialize<ServerComponent>(unprotectedSecondServerComponent, ServerComponentSerializationSettings.JsonSerializationOptions); 461var marker = JsonSerializer.Deserialize<ComponentMarker>(match.Groups[1].Value, ServerComponentSerializationSettings.JsonSerializationOptions); 468var serverComponent = JsonSerializer.Deserialize<ServerComponent>(unprotectedServerComponent, ServerComponentSerializationSettings.JsonSerializationOptions); 500var marker = JsonSerializer.Deserialize<ComponentMarker>(match.Groups[1].Value, ServerComponentSerializationSettings.JsonSerializationOptions); 507var serverComponent = JsonSerializer.Deserialize<ServerComponent>(unprotectedServerComponent, ServerComponentSerializationSettings.JsonSerializationOptions); 540var preambleMarker = JsonSerializer.Deserialize<ComponentMarker>(preamble, ServerComponentSerializationSettings.JsonSerializationOptions); 547var serverComponent = JsonSerializer.Deserialize<ServerComponent>(unprotectedServerComponent, ServerComponentSerializationSettings.JsonSerializationOptions); 567var epilogueMarker = JsonSerializer.Deserialize<ComponentMarker>(epilogue, ServerComponentSerializationSettings.JsonSerializationOptions); 591var preambleMarker = JsonSerializer.Deserialize<ComponentMarker>(preamble, ServerComponentSerializationSettings.JsonSerializationOptions); 598var serverComponent = JsonSerializer.Deserialize<ServerComponent>(unprotectedServerComponent, ServerComponentSerializationSettings.JsonSerializationOptions); 618var epilogueMarker = JsonSerializer.Deserialize<ComponentMarker>(epilogue, ServerComponentSerializationSettings.JsonSerializationOptions); 1074var marker = JsonSerializer.Deserialize<ComponentMarker>(markerText, ServerComponentSerializationSettings.JsonSerializationOptions); 1081var serverComponent = JsonSerializer.Deserialize<ServerComponent>(unprotectedServerComponent, ServerComponentSerializationSettings.JsonSerializationOptions); 1103var marker = JsonSerializer.Deserialize<ComponentMarker>(markerText, ServerComponentSerializationSettings.JsonSerializationOptions); 1110var serverComponent = JsonSerializer.Deserialize<ServerComponent>(unprotectedServerComponent, ServerComponentSerializationSettings.JsonSerializationOptions); 1131var marker = JsonSerializer.Deserialize<ComponentMarker>(markerText, ServerComponentSerializationSettings.JsonSerializationOptions); 1134var parameterValues = JsonSerializer.Deserialize<object[]>(Convert.FromBase64String(marker.ParameterValues), WebAssemblyComponentSerializationSettings.JsonSerializationOptions); 1144var marker = JsonSerializer.Deserialize<ComponentMarker>(markerText, ServerComponentSerializationSettings.JsonSerializationOptions); 1147var parameterValues = JsonSerializer.Deserialize<object[]>(Convert.FromBase64String(marker.ParameterValues), WebAssemblyComponentSerializationSettings.JsonSerializationOptions); 1173var preambleMarker = JsonSerializer.Deserialize<ComponentMarker>(preamble, ServerComponentSerializationSettings.JsonSerializationOptions);
WebRootComponentParametersTest.cs (1)
179var jsonElement = JsonSerializer.SerializeToElement(parameterValues[i]);
Microsoft.AspNetCore.Components.Server (9)
Circuits\CircuitOptionsJavaScriptInitializersConfiguration.cs (1)
24var initializers = JsonSerializer.Deserialize<string[]>(file.CreateReadStream());
Circuits\ComponentParameterDeserializer.cs (1)
65var parameterValue = JsonSerializer.Deserialize(
Circuits\ServerComponentDeserializer.cs (3)
96var markers = JsonSerializer.Deserialize<IEnumerable<ComponentMarker>>(serializedComponentRecords, ServerComponentSerializationSettings.JsonSerializationOptions); 259result = JsonSerializer.Deserialize<ServerComponent>( 299result = JsonSerializer.Deserialize<RootComponentOperationBatch>(
ProtectedBrowserStorage\ProtectedBrowserStorage.cs (2)
125var json = JsonSerializer.Serialize(value, options: JsonSerializerOptionsProvider.Options); 136return JsonSerializer.Deserialize<TValue>(json, options: JsonSerializerOptionsProvider.Options)!;
src\Shared\Components\PrerenderComponentApplicationStore.cs (2)
33var state = JsonSerializer.Deserialize( 53JsonSerializer.SerializeToUtf8Bytes(state);
Microsoft.AspNetCore.Components.Server.Tests (6)
Circuits\CircuitHostTest.cs (1)
696var jsonElement = JsonSerializer.SerializeToElement(parameterValues[i]);
Circuits\RemoteRendererTest.cs (1)
693var jsonElement = JsonSerializer.SerializeToElement(parameterValues[i]);
Circuits\ServerComponentDeserializerTest.cs (3)
427JsonSerializer.Serialize( 432=> JsonSerializer.Serialize(batch, ServerComponentSerializationSettings.JsonSerializationOptions); 444JsonSerializer.Serialize(markers, ServerComponentSerializationSettings.JsonSerializationOptions);
src\Components\Endpoints\src\DependencyInjection\ServerComponentSerializer.cs (1)
44var serializedServerComponentBytes = JsonSerializer.SerializeToUtf8Bytes(serverComponent, ServerComponentSerializationSettings.JsonSerializationOptions);
Microsoft.AspNetCore.Components.Tests (12)
BindConverterTest.cs (3)
292var expected = JsonSerializer.Serialize(value); 404return JsonSerializer.Deserialize<Person>(text); 424return JsonSerializer.Serialize((Person)value);
Lifetime\ComponentApplicationStateTest.cs (7)
17["MyState"] = JsonSerializer.SerializeToUtf8Bytes(new byte[] { 1, 2, 3, 4 }) 51["MyState"] = JsonSerializer.SerializeToUtf8Bytes(new byte[] { 1, 2, 3, 4 }) 79Assert.Equal(myState, JsonSerializer.Deserialize<byte[]>(stored)); 115Assert.Equal(myState, JsonSerializer.Deserialize<byte[]>(stored)); 133Assert.Null(JsonSerializer.Deserialize<byte[]>(stored)); 141var serialized = JsonSerializer.SerializeToUtf8Bytes(myState); 159var serialized = JsonSerializer.SerializeToUtf8Bytes<byte[]>(null);
Lifetime\ComponentStatePersistenceManagerTest.cs (2)
25["MyState"] = JsonSerializer.SerializeToUtf8Bytes(data) 100Assert.Equal(data, JsonSerializer.Deserialize<byte[]>(persisted.ToArray()));
Microsoft.AspNetCore.Components.Web (5)
JSComponents\JSComponentInterop.cs (3)
104ParameterKind.Value => JsonSerializer.Deserialize( 109JsonSerializer.Deserialize<IJSObjectReference>(parameterJsonValue, jsonOptions)), 112JsonSerializer.Deserialize<IJSObjectReference>(parameterJsonValue, jsonOptions)),
WebEventData\WebEventData.cs (1)
79return (EventArgs)JsonSerializer.Deserialize(eventArgsJson.GetRawText(), eventArgsType, jsonSerializerOptions)!;
WebRenderer.cs (1)
132var argsJson = JsonSerializer.Serialize(args, newJsonOptions);
Microsoft.AspNetCore.Components.Web.Tests (12)
WebEventData\ChangeEventArgsReaderTest.cs (1)
65var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
WebEventData\ClipboardEventArgsReaderTest.cs (1)
29var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
WebEventData\DragEventArgsReaderTest.cs (1)
83var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
WebEventData\ErrorEventArgsReaderTest.cs (1)
38var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
WebEventData\FocusEventArgsReaderTest.cs (1)
30var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
WebEventData\KeyboardEventArgsReaderTest.cs (1)
48var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
WebEventData\MouseEventArgsReaderTest.cs (1)
68var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
WebEventData\PointerEventArgsReaderTest.cs (1)
60var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
WebEventData\ProgressEventArgsReaderTest.cs (1)
35var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
WebEventData\TouchEventArgsReaderTest.cs (1)
113var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
WebEventData\WebEventDescriptorReaderTest.cs (1)
67var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
WebEventData\WheelEventArgsReaderTest.cs (1)
53var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options);
Microsoft.AspNetCore.Components.WebAssembly (6)
Prerendering\WebAssemblyComponentParameterDeserializer.cs (3)
60var parameterValue = JsonSerializer.Deserialize( 81return JsonSerializer.Deserialize(parametersDefinitions, WebAssemblyJsonSerializerContext.Default.ComponentParameterArray)!; 87return JsonSerializer.Deserialize(parameterValues, WebAssemblyJsonSerializerContext.Default.IListObject)!;
Services\DefaultWebAssemblyJSRuntime.cs (1)
116var deserialized = JsonSerializer.Deserialize(
src\Shared\Components\PrerenderComponentApplicationStore.cs (2)
33var state = JsonSerializer.Deserialize( 53JsonSerializer.SerializeToUtf8Bytes(state);
Microsoft.AspNetCore.Components.WebAssembly.Server (2)
TargetPickerUi.cs (2)
52var msg = JsonSerializer.Serialize(args); 425return JsonSerializer.Deserialize<BrowserTab[]>(jsonResponse, JsonOptions)!;
Microsoft.AspNetCore.Components.WebAssembly.Tests (2)
JSObjectReferenceJsonConverterTest.cs (2)
28var deserialized = (JSObjectReference)JsonSerializer.Deserialize<IJSObjectReference>(json, JsonSerializerOptions)!; 42var deserialized = (JSInProcessObjectReference)JsonSerializer.Deserialize<IJSInProcessObjectReference>(json, JsonSerializerOptions)!;
Microsoft.AspNetCore.Components.WebView (4)
IpcCommon.cs (2)
34return $"{_ipcMessagePrefix}{JsonSerializer.Serialize(messageTypeAndArgs, JsonSerializerOptionsProvider.Options)}"; 44var parsed = (JsonElement[])JsonSerializer.Deserialize(messageAfterPrefix, typeof(JsonElement[]), JsonSerializerOptionsProvider.Options);
src\Shared\StaticWebAssets\ManifestStaticWebAssetFileProvider.cs (2)
319return JsonSerializer.Deserialize( 379var parsed = JsonSerializer.Deserialize(ref reader, SourceGenerationContext.DefaultWithConverter.IDictionaryStringStaticWebAssetNode)!;
Microsoft.AspNetCore.Diagnostics (1)
DeveloperExceptionPage\DeveloperExceptionPageMiddlewareImpl.cs (1)
262problemDetails.Extensions["exception"] = JsonSerializer.SerializeToElement(new ExceptionExtensionData
Microsoft.AspNetCore.Grpc.JsonTranscoding (17)
Internal\Json\AnyConverter.cs (5)
50data = (IMessage)JsonSerializer.Deserialize(valueField, descriptor.ClrType, options)!; 54data = (IMessage)JsonSerializer.Deserialize(d.RootElement, descriptor.ClrType, options)!; 89JsonSerializer.Serialize(writer, wrappedValue, wrappedValue.GetType(), options); 93JsonSerializer.Serialize(writer, valueMessage, valueMessage.GetType(), options); 118JsonSerializer.Serialize(writer, value, value.GetType(), options);
Internal\Json\JsonConverterHelper.cs (2)
139var newValues = (IDictionary)JsonSerializer.Deserialize(ref reader, repeatedFieldType, options)!; 153var newValues = (IList)JsonSerializer.Deserialize(ref reader, repeatedFieldType, options)!;
Internal\Json\ListValueConverter.cs (1)
30JsonSerializer.Serialize(writer, list, list.GetType(), options);
Internal\Json\StructConverter.cs (1)
41JsonSerializer.Serialize(writer, v, v.GetType(), options);
Internal\Json\ValueConverter.cs (3)
28var structMessage = JsonSerializer.Deserialize(ref reader, field.MessageType.ClrType, options); 35var list = JsonSerializer.Deserialize(ref reader, field.MessageType.ClrType, options); 80JsonSerializer.Serialize(writer, v, v.GetType(), options);
Internal\Json\WrapperConverter.cs (2)
21var value = JsonSerializer.Deserialize(ref reader, t, options); 31JsonSerializer.Serialize(writer, innerValue, innerValue.GetType(), options);
Internal\JsonRequestHelpers.cs (3)
172await JsonSerializer.SerializeAsync(stream, responseBody, options, cancellationToken); 233bodyContent = (await JsonSerializer.DeserializeAsync(stream, type, serializerOptions))!; 245bodyContent = (IMessage)(await JsonSerializer.DeserializeAsync(stream, serverCallContext.DescriptorInfo.BodyDescriptor.ClrType, serializerOptions))!;
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (5)
ConverterTests\JsonConverterReadTests.cs (2)
654var objectNew = JsonSerializer.Deserialize<TValue>(value, jsonSerializerOptions)!; 682var ex = Assert.ThrowsAny<Exception>(() => JsonSerializer.Deserialize<TValue>(value, jsonSerializerOptions));
ConverterTests\JsonConverterWriteTests.cs (3)
230var json = JsonSerializer.Serialize(v, jsonSerializerOptions); 245var json = JsonSerializer.Serialize(v, jsonSerializerOptions); 541var jsonNew = JsonSerializer.Serialize(value, jsonSerializerOptions);
Microsoft.AspNetCore.Grpc.Microbenchmarks (2)
Json\JsonReading.cs (1)
35JsonSerializer.Deserialize(_requestJson, typeof(HelloRequest), _serializerOptions);
Json\JsonWriting.cs (1)
36JsonSerializer.Serialize(_request, _serializerOptions);
Microsoft.AspNetCore.Hosting (2)
src\Shared\StaticWebAssets\ManifestStaticWebAssetFileProvider.cs (2)
319return JsonSerializer.Deserialize( 379var parsed = JsonSerializer.Deserialize(ref reader, SourceGenerationContext.DefaultWithConverter.IDictionaryStringStaticWebAssetNode)!;
Microsoft.AspNetCore.Http.Abstractions.Tests (12)
HttpValidationProblemDetailsJsonConverterTest.cs (4)
30JsonSerializer.Serialize(writer, problemDetails, JsonSerializerOptions); 63var problemDetails = JsonSerializer.Deserialize<HttpValidationProblemDetails>(ref reader, JsonSerializerOptions); 106var problemDetails = JsonSerializer.Deserialize<HttpValidationProblemDetails>(ref reader, JsonSerializerOptions); 145var problemDetails = JsonSerializer.Deserialize<HttpValidationProblemDetails>(json, JsonSerializerOptions);
ProblemDetailsJsonConverterTest.cs (8)
26JsonSerializer.Deserialize(ref reader, typeof(ProblemDetails), JsonSerializerOptions); 46var problemDetails = JsonSerializer.Deserialize<ProblemDetails>(ref reader, JsonSerializerOptions); 77var problemDetails = JsonSerializer.Deserialize<ProblemDetails>(json, JsonSerializerOptions); 109var problemDetails = JsonSerializer.Deserialize<ProblemDetails>(json, serializerOptions); 141var problemDetails = JsonSerializer.Deserialize<ProblemDetails>(ref reader, JsonSerializerOptions); 181JsonSerializer.Serialize(writer, value, JsonSerializerOptions); 205JsonSerializer.Serialize(writer, value, JsonSerializerOptions); 236JsonSerializer.Serialize(writer, value, JsonSerializerOptions);
Microsoft.AspNetCore.Http.Extensions (16)
HttpRequestJsonExtensions.cs (5)
75return await JsonSerializer.DeserializeAsync<TValue>(inputStream, options, cancellationToken); 113return await JsonSerializer.DeserializeAsync(inputStream, jsonTypeInfo, cancellationToken); 151return await JsonSerializer.DeserializeAsync(inputStream, jsonTypeInfo, cancellationToken); 213return await JsonSerializer.DeserializeAsync(inputStream, type, options, cancellationToken); 255return await JsonSerializer.DeserializeAsync(inputStream, type, context, cancellationToken);
HttpResponseJsonExtensions.cs (10)
99return JsonSerializer.SerializeAsync(response.BodyWriter, value, options, cancellationToken); 130return JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken); 137await JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken); 172return JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken); 179await JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken); 195await JsonSerializer.SerializeAsync(body, value, options, cancellationToken); 279return JsonSerializer.SerializeAsync(response.BodyWriter, value, type, options, cancellationToken); 293await JsonSerializer.SerializeAsync(body, value, type, options, cancellationToken); 329return JsonSerializer.SerializeAsync(response.BodyWriter, value, type, context, cancellationToken); 336await JsonSerializer.SerializeAsync(body, value, type, context, cancellationToken);
JsonOptions.cs (1)
27TypeInfoResolver = JsonSerializer.IsReflectionEnabledByDefault ? CreateDefaultTypeResolver() : JsonTypeInfoResolver.Combine()
Microsoft.AspNetCore.Http.Extensions.Tests (39)
ProblemDetailsDefaultWriterTest.cs (17)
49var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream, SerializerOptions); 87var result = await JsonSerializer.DeserializeAsync<Dictionary<string, object>>(stream, JsonSerializerOptions.Default); 119var result = await JsonSerializer.DeserializeAsync<Dictionary<string, object>>(stream, JsonSerializerOptions.Default); 154var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream, SerializerOptions); 194var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream, SerializerOptions); 234var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream, SerializerOptions); 273var problemDetails = await JsonSerializer.DeserializeAsync<HttpValidationProblemDetails>(stream, SerializerOptions); 316var problemDetails = await JsonSerializer.DeserializeAsync<HttpValidationProblemDetails>(stream, SerializerOptions); 359var problemDetails = await JsonSerializer.DeserializeAsync<CustomProblemDetails>(stream, options.SerializerOptions); 402var problemDetails = await JsonSerializer.DeserializeAsync<CustomProblemDetails>(stream, options.SerializerOptions); 445var problemDetails = await JsonSerializer.DeserializeAsync<CustomProblemDetails>(stream, options.SerializerOptions); 479var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream, SerializerOptions); 526var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream, options.SerializerOptions); 533var expectedExtension = JsonSerializer.SerializeToElement(customExtensionData, options.SerializerOptions); 559var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream, SerializerOptions); 595var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream, SerializerOptions); 627var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream, SerializerOptions);
RequestDelegateFactoryTests.cs (5)
850var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(originalTodo); 1354var deserializedResponseBody = JsonSerializer.Deserialize<JsonTodoChild>(responseBodyStream.ToArray(), new JsonSerializerOptions 2509var deserializedResponseBody = JsonSerializer.Deserialize<TodoStruct>(responseBodyStream.ToArray(), new JsonSerializerOptions 2875var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(new object()); 3545var body = await JsonSerializer.DeserializeAsync<JsonTodo>(context.Request.Body);
RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (2)
225var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(requestData); 243var deserializedObject = JsonSerializer.Deserialize<T>(body, new JsonSerializerOptions()
RequestDelegateGenerator\RequestDelegateCreationTests.Arrays.cs (5)
624var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(new string[] { "ValueFromBody" }); 651var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(new string[] { "ValueFromBody" }); 678var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(new string[] { "ValueFromBody" }); 705var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(new string[] { "ValueFromBody" }); 732var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(new string[] { "ValueFromBody" });
RequestDelegateGenerator\RequestDelegateCreationTests.BindAsync.cs (2)
211var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(originalTodo); 267var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(originalTodo);
RequestDelegateGenerator\RequestDelegateCreationTests.JsonBody.cs (6)
88var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(requestData); 227var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(new 268var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(new 309var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(new 350var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(new 429var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(targetStruct);
RequestDelegateGenerator\RequestDelegateCreationTests.Responses.cs (1)
315var deserializedResponseBody = JsonSerializer.Deserialize<Todo>(((MemoryStream)httpContext.Response.Body).ToArray(), new JsonSerializerOptions
RequestDelegateGenerator\SharedTypes.cs (1)
92var body = await JsonSerializer.DeserializeAsync<JsonTodo>(context.Request.Body);
Microsoft.AspNetCore.Http.Microbenchmarks (3)
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (2)
225var requestBodyBytes = JsonSerializer.SerializeToUtf8Bytes(requestData); 243var deserializedObject = JsonSerializer.Deserialize<T>(body, new JsonSerializerOptions()
src\Http\Http.Extensions\test\RequestDelegateGenerator\SharedTypes.cs (1)
92var body = await JsonSerializer.DeserializeAsync<JsonTodo>(context.Request.Body);
Microsoft.AspNetCore.Http.Results.Tests (18)
HttpResultsHelperTests.cs (6)
40var body = JsonSerializer.Deserialize<TodoStruct>(responseBodyStream.ToArray(), serializerOptions); 71var body = JsonSerializer.Deserialize<Todo>(responseBodyStream.ToArray(), serializerOptions); 104var body = JsonSerializer.Deserialize<TodoChild>(responseBodyStream.ToArray(), serializerOptions); 138var body = JsonSerializer.Deserialize<TodoChild>(responseBodyStream.ToArray(), serializerOptions); 172var body = JsonSerializer.Deserialize<TodoJsonChild>(responseBodyStream.ToArray(), serializerOptions); 200var body = JsonSerializer.Deserialize<JsonTodo[]>(responseBodyStream.ToArray(), serializerOptions);
JsonResultTests.cs (5)
103var responseDetails = JsonSerializer.Deserialize<Todo>(stream); 109Assert.Equal(JsonSerializer.Serialize(value, options: jsonOptions), Encoding.UTF8.GetString(stream.ToArray())); 135var responseDetails = JsonSerializer.Deserialize<ProblemDetails>(stream, JsonSerializerOptions.Web); 164var responseDetails = JsonSerializer.Deserialize<HttpValidationProblemDetails>(stream, JsonSerializerOptions.Web); 196var responseDetails = JsonSerializer.Deserialize<HttpValidationProblemDetails>(stream, JsonSerializerOptions.Web);
ProblemResultTests.cs (5)
38var responseDetails = JsonSerializer.Deserialize<ProblemDetails>(stream, JsonSerializerOptions.Web); 70var responseDetails = JsonSerializer.Deserialize<ProblemDetails>(stream, JsonSerializerOptions.Web); 99var responseDetails = JsonSerializer.Deserialize<HttpValidationProblemDetails>(stream, JsonSerializerOptions.Web); 131var responseDetails = JsonSerializer.Deserialize<HttpValidationProblemDetails>(stream, JsonSerializerOptions.Web); 163var responseDetails = JsonSerializer.Deserialize<HttpValidationProblemDetails>(stream, JsonSerializerOptions.Web);
ValidationProblemResultTests.cs (2)
42var responseDetails = JsonSerializer.Deserialize<ProblemDetails>(stream, JsonSerializerOptions.Web); 74var responseDetails = JsonSerializer.Deserialize<ProblemDetails>(stream, JsonSerializerOptions.Web);
Microsoft.AspNetCore.Identity.UI (2)
Areas\Identity\Pages\V4\Account\Manage\DownloadPersonalData.cshtml.cs (1)
78return new FileContentResult(JsonSerializer.SerializeToUtf8Bytes(personalData), "application/json");
Areas\Identity\Pages\V5\Account\Manage\DownloadPersonalData.cshtml.cs (1)
78return new FileContentResult(JsonSerializer.SerializeToUtf8Bytes(personalData), "application/json");
Microsoft.AspNetCore.Mvc.Core (13)
Formatters\SystemTextJsonInputFormatter.cs (3)
12/// A <see cref="TextInputFormatter"/> for JSON content that uses <see cref="JsonSerializer"/>. 41/// Gets the <see cref="JsonSerializerOptions"/> used to configure the <see cref="JsonSerializer"/>. 66model = await JsonSerializer.DeserializeAsync(inputStream, context.ModelType, SerializerOptions);
Formatters\SystemTextJsonOutputFormatter.cs (6)
14/// A <see cref="TextOutputFormatter"/> for JSON content that uses <see cref="JsonSerializer"/>. 52/// Gets the <see cref="JsonSerializerOptions"/> used to configure the <see cref="JsonSerializer"/>. 94await JsonSerializer.SerializeAsync(responseWriter, context.Object, jsonTypeInfo, httpContext.RequestAborted); 98await JsonSerializer.SerializeAsync(responseWriter, context.Object, SerializerOptions, httpContext.RequestAborted); 114await JsonSerializer.SerializeAsync(transcodingStream, context.Object, jsonTypeInfo); 118await JsonSerializer.SerializeAsync(transcodingStream, context.Object, SerializerOptions);
FromBodyAttribute.cs (1)
16/// In the case of ASP.NET Core Minimal APIs, the body is deserialized by <see cref="System.Text.Json.JsonSerializer"/>.
Infrastructure\SystemTextJsonResultExecutor.cs (2)
69await JsonSerializer.SerializeAsync(responseWriter, value, objectType, jsonSerializerOptions, context.HttpContext.RequestAborted); 82await JsonSerializer.SerializeAsync(transcodingStream, value, objectType, jsonSerializerOptions, context.HttpContext.RequestAborted);
JsonOptions.cs (1)
45TypeInfoResolver = JsonSerializer.IsReflectionEnabledByDefault ? CreateDefaultTypeResolver() : JsonTypeInfoResolver.Combine()
Microsoft.AspNetCore.Mvc.Core.Test (20)
Formatters\SystemTextJsonOutputFormatterTest.cs (2)
91await JsonSerializer.SerializeAsync(expected, LargeAsync(), JsonSerializerOptions.Web); 287if (JsonSerializer.IsReflectionEnabledByDefault)
Infrastructure\DefaultApiProblemDetailsWriterTest.cs (3)
45var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream, JsonSerializerOptions.Web); 84var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream, JsonSerializerOptions.Web); 115var problemDetails = await JsonSerializer.DeserializeAsync<ProblemDetails>(stream);
Infrastructure\JsonResultExecutorTestBase.cs (10)
26var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 46var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 67var expected = Encoding.Unicode.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 91var expected = Encoding.Unicode.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 111var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 135var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 161var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 182var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize( 331var expected = JsonSerializer.Serialize(new[] { "Hello", "world" }); 349var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new[] { 1, 2 }));
Infrastructure\ValidationProblemDetailsJsonConverterTest.cs (5)
30var problemDetails = JsonSerializer.Deserialize<ValidationProblemDetails>(ref reader, JsonSerializerOptions); 72var problemDetails = JsonSerializer.Deserialize<ValidationProblemDetails>(ref reader, JsonSerializerOptions); 110var problemDetails = JsonSerializer.Deserialize<ValidationProblemDetails>(json, JsonSerializerOptions); 149JsonSerializer.Serialize(writer, problemDetails, JsonSerializerOptions); 182JsonSerializer.Serialize(writer, problemDetails, options);
Microsoft.AspNetCore.Mvc.FunctionalTests (8)
AsyncEnumerableTestBase.cs (1)
50var projects = JsonSerializer.Deserialize<List<Project>>(content, TestJsonSerializerOptionsProvider.Options);
BasicTests.cs (7)
437var result = JsonSerializer.Deserialize<Product>(response, TestJsonSerializerOptionsProvider.Options); 451var result = JsonSerializer.Deserialize<Product[]>(response, TestJsonSerializerOptionsProvider.Options); 470var assemblyParts = JsonSerializer.Deserialize<IList<string>>(response, TestJsonSerializerOptionsProvider.Options); 541var data = JsonSerializer.Deserialize<BindPropertyControllerData>(content, TestJsonSerializerOptionsProvider.Options); 564var data = JsonSerializer.Deserialize<BindPropertyControllerData>(content, TestJsonSerializerOptionsProvider.Options); 586var data = JsonSerializer.Deserialize<BindPropertyControllerData>(content, TestJsonSerializerOptionsProvider.Options); 656var problemDetails = JsonSerializer.Deserialize<ValidationProblemDetails>(content, TestJsonSerializerOptionsProvider.Options);
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (11)
NewtonsoftJsonResultExecutorTest.cs (1)
35var expected = System.Text.Json.JsonSerializer.Serialize(new[] { "Hello", "world" });
src\Mvc\Mvc.Core\test\Infrastructure\JsonResultExecutorTestBase.cs (10)
26var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 46var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 67var expected = Encoding.Unicode.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 91var expected = Encoding.Unicode.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 111var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 135var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 161var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new { foo = "abcd" })); 182var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize( 331var expected = JsonSerializer.Serialize(new[] { "Hello", "world" }); 349var expected = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(new[] { 1, 2 }));
Microsoft.AspNetCore.Mvc.TagHelpers.Test (2)
ProtectedPrerenderComponentApplicationStateTest.cs (2)
45var persistedState = Convert.ToBase64String(_protector.Protect(JsonSerializer.SerializeToUtf8Bytes(expectedState))); 66var persistedState = Convert.ToBase64String(JsonSerializer.SerializeToUtf8Bytes(expectedState));
Microsoft.AspNetCore.Mvc.Testing (1)
WebApplicationFactory.cs (1)
239var data = JsonSerializer.Deserialize(File.ReadAllBytes(file), CustomJsonSerializerContext.Default.IDictionaryStringString)!;
Microsoft.AspNetCore.Mvc.ViewFeatures (1)
Rendering\SystemTextJsonHelper.cs (1)
25var json = JsonSerializer.Serialize(value, _htmlSafeJsonSerializerOptions);
Microsoft.AspNetCore.OpenApi (4)
Extensions\JsonNodeSchemaExtensions.cs (1)
164schema[OpenApiSchemaKeywords.DefaultKeyword] = JsonSerializer.SerializeToNode(defaultValue, jsonTypeInfo);
Schemas\OpenApiJsonSchema.Helpers.cs (2)
33values.Add((T)JsonSerializer.Deserialize(ref reader, typeof(T), OpenApiJsonSchemaContext.Default)!); 78values[key] = (T)JsonSerializer.Deserialize(ref reader, typeof(T), OpenApiJsonSchemaContext.Default)!;
Services\Schemas\OpenApiSchemaService.cs (1)
141var deserializedSchema = JsonSerializer.Deserialize(schemaAsJsonObject, _jsonSchemaContext.OpenApiJsonSchema);
Microsoft.AspNetCore.Routing.FunctionalTests (5)
MinimalFormTests.cs (5)
67var result = JsonSerializer.Deserialize<Todo>(body, JsonSerializerOptions.Web); 127var result = JsonSerializer.Deserialize<Todo>(body, JsonSerializerOptions.Web); 288var result = JsonSerializer.Deserialize<Todo>(body, JsonSerializerOptions.Web); 335var result = JsonSerializer.Deserialize<Todo>(body, JsonSerializerOptions.Web); 495var result = JsonSerializer.Deserialize<Todo>(body, JsonSerializerOptions.Web);
Microsoft.AspNetCore.SignalR.Protocols.Json (2)
Protocol\JsonHubProtocol.cs (2)
917private void SerializeObject(Utf8JsonWriter writer, object? value) => JsonSerializer.Serialize(writer, value, _payloadSerializerOptions); 921private object? DeserializeObject(ref Utf8JsonReader reader, Type type) => JsonSerializer.Deserialize(ref reader, type, _payloadSerializerOptions);
Microsoft.AspNetCore.StaticAssets (1)
StaticAssetsManifest.cs (1)
32var result = JsonSerializer.Deserialize(content, StaticAssetsManifestJsonContext.Default.StaticAssetsManifest) ??
Microsoft.AspNetCore.StaticAssets.Tests (1)
StaticAssetsIntegrationTests.cs (1)
540JsonSerializer.Serialize(writer, manifest);
Microsoft.CodeAnalysis.CSharp.EditorFeatures (2)
StringCopyPaste\StringCopyPasteData.cs (2)
32return JsonSerializer.Serialize(this, typeof(StringCopyPasteData)); 48var value = JsonSerializer.Deserialize(JsonDocument.Parse(json), typeof(StringCopyPasteData));
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
Rename\CSharpInlineRenameServiceTests.cs (1)
74var expectedContext = JsonSerializer.Deserialize<ImmutableDictionary<string, ImmutableArray<(string, string)>>>(expectedContextJson, serializationOptions);
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (3)
LanguageServer\AbstractLanguageServerProtocolTests.cs (3)
127var expectedStr = JsonSerializer.Serialize(expected, JsonSerializerOptions); 128var actualStr = JsonSerializer.Serialize(actual, JsonSerializerOptions); 283Data = JsonSerializer.SerializeToElement(new CompletionResolveData(resultId, ProtocolConversions.DocumentToTextDocumentIdentifier(document)), JsonSerializerOptions),
Microsoft.CodeAnalysis.ExternalAccess.Razor (4)
Cohost\RazorDynamicRegistrationServiceFactory.cs (1)
81var serializedClientCapabilities = JsonSerializer.Serialize(clientCapabilities, ProtocolConversions.LspJsonSerializerOptions);
Cohost\RazorSemanticTokensRefreshQueueWrapper.cs (1)
33var clientCapabilities = JsonSerializer.Deserialize<VSInternalClientCapabilities>(clientCapabilitiesString) ?? new();
Testing\RazorTestLanguageServerFactory.cs (2)
89var clientCapabilitiesJson = JsonSerializer.Serialize(clientCapabilities, _options); 91var serverCapabilities = JsonSerializer.Deserialize<VSInternalServerCapabilities>(serverCapabilitiesJson, _options);
Microsoft.CodeAnalysis.ExternalAccess.Xaml (2)
External\ResolveDataConversions.cs (2)
24var resolveData = JsonSerializer.Deserialize<DataResolveData>((JsonElement)requestData); 40resolveData = JsonSerializer.Deserialize<DataIdResolveData>(token);
Microsoft.CodeAnalysis.Features (1)
Intents\IntentDataProvider.cs (1)
33return JsonSerializer.Deserialize<T>(_serializedIntentData, s_serializerOptions.Value);
Microsoft.CodeAnalysis.LanguageServer (1)
Program.cs (1)
139Console.WriteLine(JsonSerializer.Serialize(new NamedPipeInformation(clientPipeName)));
Microsoft.CodeAnalysis.LanguageServer.Protocol (43)
Handler\CodeActions\CodeActionFixAllResolveHandler.cs (1)
70var resolveData = JsonSerializer.Deserialize<CodeActionResolveData>((JsonElement)request.Data!, ProtocolConversions.LspJsonSerializerOptions);
Handler\CodeActions\CodeActionResolveHandler.cs (1)
101var resolveData = JsonSerializer.Deserialize<CodeActionResolveData>((JsonElement)request.Data!, ProtocolConversions.LspJsonSerializerOptions);
Handler\CodeLens\CodeLensResolveHandler.cs (1)
90var resolveData = JsonSerializer.Deserialize<CodeLensResolveData>((JsonElement)codeLens.Data, ProtocolConversions.LspJsonSerializerOptions);
Handler\Completion\CompletionResolveHandler.cs (1)
128var resolveData = JsonSerializer.Deserialize<DocumentResolveData>((JsonElement)request.Data);
Handler\Completion\Extensions.cs (1)
55var resolveData = JsonSerializer.Deserialize<CompletionResolveData>((JsonElement)request.Data, ProtocolConversions.LspJsonSerializerOptions);
Handler\InlayHint\InlayHintResolveHandler.cs (1)
85var resolveData = JsonSerializer.Deserialize<InlayHintResolveData>((JsonElement)inlayHint.Data, ProtocolConversions.LspJsonSerializerOptions);
Handler\ServerLifetime\InitializeHandler.cs (1)
44m["capabilities"] = JsonSerializer.Serialize(serverCapabilities, ProtocolConversions.LspJsonSerializerOptions);
Protocol\Converters\FormattingOptionsConverter.cs (1)
141JsonSerializer.Serialize(writer, item.Value, options);
Protocol\Converters\InitializeParamsWorkspaceFoldersConverter.cs (2)
31return JsonSerializer.Deserialize<WorkspaceFolder[]>(ref reader, options) ?? []; 36JsonSerializer.Serialize(writer, value, options);
Protocol\Converters\NaturalObjectConverter.cs (2)
28JsonSerializer.Serialize(writer, value, runtimeType, options); 67return JsonSerializer.Deserialize<JsonElement>(ref reader);
Protocol\Converters\ParameterInformationConverter.cs (2)
47JsonSerializer.Serialize(writer, value.Label, options); 52JsonSerializer.Serialize(writer, value.Documentation, options);
Protocol\Converters\SumConverter.cs (2)
140private static readonly MethodInfo jsonSerializerDeserializeMethod = typeof(JsonSerializer) 272JsonSerializer.Serialize(writer, sumValue, options);
Protocol\Converters\TextDocumentSyncConverter.cs (3)
34return JsonSerializer.Deserialize<TextDocumentSyncOptions>(value)!; 38return JsonSerializer.Deserialize<TextDocumentSyncOptions>(ref reader, options)!; 47JsonSerializer.Serialize(writer, value, options);
Protocol\Extensions\Converters\VSExtensionConverter.cs (3)
25return JsonSerializer.Deserialize<TExtension>(ref reader, options); 34JsonSerializer.Serialize(writer, extension, options); 40JsonSerializer.Serialize(writer, (object)value!, DropConverter(options));
Protocol\Internal\Converters\ObjectContentConverter.cs (1)
78return JsonSerializer.Deserialize(ref reader, objectType, options);
Protocol\Internal\Efficiency\OptimizedVSCompletionListJsonConverter.cs (16)
45JsonSerializer.Serialize(writer, completionList.ContinueCharacters, options); 51JsonSerializer.Serialize(writer, completionList.Data, options); 57JsonSerializer.Serialize(writer, completionList.CommitCharacters, options); 90JsonSerializer.Serialize(writer, completionList.ItemDefaults, options); 106jsonString = JsonSerializer.Serialize(vsCompletionItem.Icon, options); 116JsonSerializer.Serialize(writer, vsCompletionItem.Description, options); 124jsonString = JsonSerializer.Serialize(basicCommitCharacters, options); 136jsonString = JsonSerializer.Serialize(augmentedCommitCharacters, options); 156JsonSerializer.Serialize(writer, completionItem.LabelDetails, options); 169JsonSerializer.Serialize(writer, completionItem.Documentation, options); 201JsonSerializer.Serialize(writer, completionItem.TextEdit, options); 207JsonSerializer.Serialize(writer, completionItem.TextEditText, options); 213JsonSerializer.Serialize(writer, completionItem.AdditionalTextEdits, options); 220jsonString = JsonSerializer.Serialize(completionItem.CommitCharacters, options); 231JsonSerializer.Serialize(writer, completionItem.Command, options); 237JsonSerializer.Serialize(writer, completionItem.Data, options);
RoslynLanguageServer.cs (2)
199uri = JsonSerializer.Deserialize<Uri>(uriToken, ProtocolConversions.LspJsonSerializerOptions); 209var data = JsonSerializer.Deserialize<DocumentResolveData>(dataToken, ProtocolConversions.LspJsonSerializerOptions);
src\LanguageServer\Microsoft.CommonLanguageServerProtocol.Framework\SystemTextJsonLanguageServer.cs (2)
50return JsonSerializer.Deserialize<TRequest>(request, _jsonSerializerOptions) 94var serializedResult = JsonSerializer.SerializeToElement(result, target._jsonSerializerOptions);
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (9)
CodeActions\CodeActionsTests.cs (3)
94r => JsonSerializer.Deserialize<CodeActionResolveData>((JsonElement)r.Data!, ProtocolConversions.LspJsonSerializerOptions)!.UniqueIdentifier == titlePath[1]); 324return JsonSerializer.Deserialize<CodeActionResolveData>((JsonElement)codeAction.Data!, ProtocolConversions.LspJsonSerializerOptions); 349Data = JsonSerializer.SerializeToElement(data, ProtocolConversions.LspJsonSerializerOptions),
CodeActions\RunCodeActionsTests.cs (1)
72JsonSerializer.SerializeToElement(codeActionData, ProtocolConversions.LspJsonSerializerOptions)
CodeLens\CSharpCodeLensTests.cs (1)
390var data = JsonSerializer.Deserialize<CodeLensResolveData>(firstCodeLens.Data!.ToString(), ProtocolConversions.LspJsonSerializerOptions);
Diagnostics\DiagnosticRegistrationTests.cs (1)
56.Select(r => JsonSerializer.Deserialize<DiagnosticRegistrationOptions>((JsonElement)r.RegisterOptions!, ProtocolConversions.LspJsonSerializerOptions)!);
InlayHint\CSharpInlayHintTests.cs (1)
134var data = JsonSerializer.Deserialize<InlayHintResolveData>(firstInlayHint.Data!.ToString(), ProtocolConversions.LspJsonSerializerOptions);
References\FindAllReferencesHandlerTests.cs (1)
354.SelectMany(r => (List<object>)r).Select(r => JsonSerializer.Deserialize<T>((JsonElement)r, ProtocolConversions.LspJsonSerializerOptions))
UriTests.cs (1)
182var unencodedUri = JsonSerializer.Deserialize<LSP.DidOpenTextDocumentParams>(jsonDocument, JsonSerializerOptions)!.TextDocument.Uri;
Microsoft.CodeAnalysis.LanguageServer.UnitTests (1)
LspFileChangeWatcherTests.cs (1)
113var registration = JsonSerializer.Deserialize<DidChangeWatchedFilesRegistrationOptions>(registrationJson, ProtocolConversions.LspJsonSerializerOptions)!;
Microsoft.CodeAnalysis.Workspaces.UnitTests (1)
UtilityTest\ExceptionHelpersTests.cs (1)
69Assert.NotNull(JsonSerializer.Serialize(e));
Microsoft.CommonLanguageServerProtocol.Framework.Package (2)
SystemTextJsonLanguageServer.cs (2)
50return JsonSerializer.Deserialize<TRequest>(request, _jsonSerializerOptions) 94var serializedResult = JsonSerializer.SerializeToElement(result, target._jsonSerializerOptions);
Microsoft.DotNet.Build.Tasks.Workloads (2)
Msi\MsiProperties.wix.cs (1)
116File.WriteAllText(msiJsonPath, JsonSerializer.Serialize(properties));
Msi\WorkloadManifestMsi.wix.cs (1)
79string jsonAsString = JsonSerializer.Serialize(WorkloadPackGroups, typeof(IList<WorkloadPackGroupJson>), new JsonSerializerOptions() { WriteIndented = true });
Microsoft.DotNet.Internal.SymbolHelper (1)
SymbolPromotionHelper.cs (1)
218return await JsonSerializer.DeserializeAsync<SymbolRequestStatus>(result, s_options, cancellationToken: ct);
Microsoft.DotNet.XliffTasks (2)
Model\JsonDocument.cs (2)
26_json = JsonSerializer.Deserialize<Dictionary<string, string>>(text); 31writer.Write(JsonSerializer.Serialize(_json, typeof(Dictionary<string, string>), s_serializerOptions));
Microsoft.Extensions.AI (24)
CachingHelpers.cs (1)
58JsonSerializer.Serialize(stream, value, serializerOptions.GetTypeInfo(typeof(object)));
ChatCompletion\ChatClientStructuredOutputExtensions.cs (1)
144schema = JsonSerializer.SerializeToElement(new JsonObject
ChatCompletion\ChatCompletion{T}.cs (1)
101return JsonSerializer.Deserialize(ref reader, typeInfo);
ChatCompletion\DistributedCachingChatClient.cs (4)
53return (ChatCompletion?)JsonSerializer.Deserialize(existingJson, _jsonSerializerOptions.GetTypeInfo(typeof(ChatCompletion))); 67return (IReadOnlyList<StreamingChatCompletionUpdate>?)JsonSerializer.Deserialize(existingJson, _jsonSerializerOptions.GetTypeInfo(typeof(IReadOnlyList<StreamingChatCompletionUpdate>))); 80var newJson = JsonSerializer.SerializeToUtf8Bytes(value, _jsonSerializerOptions.GetTypeInfo(typeof(ChatCompletion))); 91var newJson = JsonSerializer.SerializeToUtf8Bytes(value, _jsonSerializerOptions.GetTypeInfo(typeof(IReadOnlyList<StreamingChatCompletionUpdate>)));
ChatCompletion\OpenTelemetryChatClient.cs (6)
446JsonSerializer.Serialize(CreateAssistantEvent(message), OtelContext.Default.AssistantEvent)); 453JsonSerializer.Serialize(new() 457JsonSerializer.SerializeToNode(result, _jsonSerializerOptions.GetTypeInfo(result.GetType())) : 465JsonSerializer.Serialize(new() 485Log(id, JsonSerializer.Serialize(new() 518JsonSerializer.SerializeToNode(fc.Arguments, _jsonSerializerOptions.GetTypeInfo(typeof(IDictionary<string, object?>))) :
Embeddings\DistributedCachingEmbeddingGenerator.cs (2)
60return JsonSerializer.Deserialize(existingJson, (JsonTypeInfo<TEmbedding>)_jsonSerializerOptions.GetTypeInfo(typeof(TEmbedding))); 73var newJson = JsonSerializer.SerializeToUtf8Bytes(value, (JsonTypeInfo<TEmbedding>)_jsonSerializerOptions.GetTypeInfo(typeof(TEmbedding)));
Embeddings\LoggingEmbeddingGenerator.cs (1)
83private string AsJson<T>(T value) => JsonSerializer.Serialize(value, _jsonSerializerOptions.GetTypeInfo(typeof(T)));
Functions\AIFunctionFactory.cs (7)
322return JsonSerializer.SerializeToElement(result, _returnTypeInfo); 328await JsonSerializer.SerializeAsync(stream, result, _returnTypeInfo, cancellationToken).ConfigureAwait(false); 381JsonElement element => JsonSerializer.Deserialize(element, typeInfo), 382JsonDocument doc => JsonSerializer.Deserialize(doc, typeInfo), 383JsonNode node => JsonSerializer.Deserialize(node, typeInfo), 392string json = JsonSerializer.Serialize(value, options.SerializerOptions.GetTypeInfo(value.GetType())); 393return JsonSerializer.Deserialize(json, typeInfo);
LoggingHelpers.cs (1)
23return JsonSerializer.Serialize(value, typeInfo);
Microsoft.Extensions.AI.Abstractions (7)
Contents\FunctionCallContent.cs (1)
53/// instances of this class with <see cref="JsonSerializer"/>; as such, upon deserialization, this property will be <see langword="null"/>.
Contents\FunctionResultContent.cs (1)
65/// instances of this class with <see cref="JsonSerializer"/>. As such, upon deserialization, this property will be <see langword="null"/>.
Utilities\AIJsonUtilities.Defaults.cs (1)
28if (JsonSerializer.IsReflectionEnabledByDefault)
Utilities\AIJsonUtilities.Schema.cs (4)
209? JsonSerializer.Serialize(defaultValue, options.GetTypeInfo(defaultValue.GetType())) 217: JsonSerializer.SerializeToElement(schemaObj, JsonContext.Default.JsonNode); 232return JsonSerializer.SerializeToElement(node, JsonContext.Default.JsonNode); 342JsonNode? defaultValue = JsonSerializer.Serialize(key.DefaultValue, options.GetTypeInfo(typeof(object)));
Microsoft.Extensions.AI.Abstractions.Tests (64)
AssertExtensions.cs (1)
70=> value is JsonElement e ? e : JsonSerializer.SerializeToElement(value, options);
ChatCompletion\ChatCompletionTests.cs (2)
145string json = JsonSerializer.Serialize(original, TestJsonSerializerContext.Default.ChatCompletion); 147ChatCompletion? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatCompletion);
ChatCompletion\ChatFinishReasonTests.cs (2)
69string? json = JsonSerializer.Serialize(role, TestJsonSerializerContext.Default.ChatFinishReason); 72ChatFinishReason? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatFinishReason);
ChatCompletion\ChatMessageTests.cs (2)
293var chatMessageJson = JsonSerializer.Serialize(new ChatMessage(ChatRole.User, contents: items) 300var deserializedMessage = JsonSerializer.Deserialize<ChatMessage>(chatMessageJson, TestJsonSerializerContext.Default.Options)!;
ChatCompletion\ChatOptionsTests.cs (2)
146string json = JsonSerializer.Serialize(options, TestJsonSerializerContext.Default.ChatOptions); 148ChatOptions? deserialized = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatOptions);
ChatCompletion\ChatResponseFormatTests.cs (9)
42Assert.Equal("{}", JsonSerializer.Serialize(f.Schema, TestJsonSerializerContext.Default.JsonElement)); 50string json = JsonSerializer.Serialize(ChatResponseFormat.Text, TestJsonSerializerContext.Default.ChatResponseFormat); 53ChatResponseFormat? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatResponseFormat); 60string json = JsonSerializer.Serialize(ChatResponseFormat.Json, TestJsonSerializerContext.Default.ChatResponseFormat); 63ChatResponseFormat? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatResponseFormat); 73string json = JsonSerializer.Serialize( 74ChatResponseFormat.ForJsonSchema(JsonSerializer.Deserialize<JsonElement>("[1,2,3]"), "name", "description"), 78ChatResponseFormat? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatResponseFormat); 80Assert.Equal("[1,2,3]", JsonSerializer.Serialize(actual.Schema, TestJsonSerializerContext.Default.JsonElement));
ChatCompletion\ChatRoleTests.cs (2)
58string? json = JsonSerializer.Serialize(role, TestJsonSerializerContext.Default.ChatRole); 61ChatRole? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatRole);
ChatCompletion\ChatToolModeTests.cs (6)
50string json = JsonSerializer.Serialize(ChatToolMode.Auto, TestJsonSerializerContext.Default.ChatToolMode); 53ChatToolMode? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatToolMode); 60string json = JsonSerializer.Serialize(ChatToolMode.RequireAny, TestJsonSerializerContext.Default.ChatToolMode); 63ChatToolMode? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatToolMode); 70string json = JsonSerializer.Serialize(ChatToolMode.RequireSpecific("myFunc"), TestJsonSerializerContext.Default.ChatToolMode); 73ChatToolMode? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatToolMode);
ChatCompletion\StreamingChatCompletionUpdateTests.cs (2)
185string json = JsonSerializer.Serialize(original, TestJsonSerializerContext.Default.StreamingChatCompletionUpdate); 187StreamingChatCompletionUpdate? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.StreamingChatCompletionUpdate);
Contents\DataContentTests{T}.cs (10)
131JsonSerializer.Serialize(CreateDataContent("data:,"), TestJsonSerializerContext.Default.Options)); 135JsonSerializer.Serialize(CreateDataContent(new Uri("http://localhost/")), TestJsonSerializerContext.Default.Options)); 139JsonSerializer.Serialize(CreateDataContent( 144JsonSerializer.Serialize(CreateDataContent( 154Assert.Throws<ArgumentNullException>("uri", () => JsonSerializer.Deserialize<DataContent>(json, TestJsonSerializerContext.Default.Options)!); 161var content = JsonSerializer.Deserialize<DataContent>("""{"mediaType":"application/octet-stream","uri":"data:;base64,AQIDBA=="}""", TestJsonSerializerContext.Default.Options)!; 170content = JsonSerializer.Deserialize<DataContent>("""{"mediaType":"application/octet-stream","uri":"http://localhost/"}""", TestJsonSerializerContext.Default.Options)!; 178content = JsonSerializer.Deserialize<DataContent>(""" 213var content = JsonSerializer.Deserialize<DataContent>(serialized, TestJsonSerializerContext.Default.Options)!; 214var reSerialization = JsonSerializer.Serialize(content, TestJsonSerializerContext.Default.Options);
Contents\FunctionCallContentTests..cs (9)
86var json = JsonSerializer.SerializeToNode(sut, TestJsonSerializerContext.Default.Options); 87var deserializedSut = JsonSerializer.Deserialize<FunctionCallContent>(json, TestJsonSerializerContext.Default.Options); 121Dictionary<string, object?> arguments = JsonSerializer.Deserialize<Dictionary<string, object?>>(""" 155var arguments = JsonSerializer.Deserialize<Dictionary<string, JsonDocument>>(""" 176var arguments = JsonSerializer.Deserialize<Dictionary<string, JsonNode>>(""" 197var arguments = JsonSerializer.Deserialize<Dictionary<string, JsonDocument>>(""" 215Dictionary<string, object?> arguments = JsonSerializer.Deserialize<Dictionary<string, object?>>(""" 233var arguments = JsonSerializer.Deserialize<Dictionary<string, JsonNode>>(""" 279argumentParser: static json => JsonSerializer.Deserialize<Dictionary<string, object?>>(json));
Contents\FunctionResultContentTests.cs (4)
72var json = JsonSerializer.Serialize(sut, TestJsonSerializerContext.Default.Options); 74var deserializedSut = JsonSerializer.Deserialize<FunctionResultContent>(json, TestJsonSerializerContext.Default.Options); 90var json = JsonSerializer.Serialize(sut, TestJsonSerializerContext.Default.Options); 91var deserializedSut = JsonSerializer.Deserialize<FunctionResultContent>(json, TestJsonSerializerContext.Default.Options);
Embeddings\EmbeddingGenerationOptionsTests.cs (2)
72string json = JsonSerializer.Serialize(options, TestJsonSerializerContext.Default.EmbeddingGenerationOptions); 74EmbeddingGenerationOptions? deserialized = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.EmbeddingGenerationOptions);
Embeddings\EmbeddingTests.cs (6)
45string json = JsonSerializer.Serialize(e, TestJsonSerializerContext.Default.Embedding); 48Embedding<Half> result = Assert.IsType<Embedding<Half>>(JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.Embedding)); 59string json = JsonSerializer.Serialize(e, TestJsonSerializerContext.Default.Embedding); 62Embedding<float> result = Assert.IsType<Embedding<float>>(JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.Embedding)); 72string json = JsonSerializer.Serialize(e, TestJsonSerializerContext.Default.Embedding); 75Embedding<double> result = Assert.IsType<Embedding<double>>(JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.Embedding));
test\Shared\JsonSchemaExporter\SchemaTestHelpers.cs (2)
69JsonSchema jsonSchema = JsonSerializer.Deserialize(schema, Context.Default.JsonSchema)!; 75JsonSerializer.Serialize(node, Context.Default.JsonNode!);
test\Shared\JsonSchemaExporter\TestTypes.cs (1)
781jObj["default"] = JsonSerializer.SerializeToNode(attr.Value);
Utilities\AIJsonUtilitiesTests.cs (2)
280JsonNode? schemaAsNode = JsonSerializer.SerializeToNode(schema, options); 292JsonNode? serializedValue = JsonSerializer.SerializeToNode(testData.Value, testData.Type, options);
Microsoft.Extensions.AI.AzureAIInference (7)
AzureAIInferenceChatClient.cs (6)
317result.AdditionalProperties["top_k"] = new BinaryData(JsonSerializer.SerializeToUtf8Bytes(topK, AIJsonUtilities.DefaultOptions.GetTypeInfo(typeof(int)))); 330byte[] data = JsonSerializer.SerializeToUtf8Bytes(prop.Value, ToolCallJsonSerializerOptions.GetTypeInfo(typeof(object))); 399JsonSerializer.SerializeToUtf8Bytes(tool, JsonContext.Default.AzureAIChatToolJson)); 432result = JsonSerializer.Serialize(resultContent.Result, ToolCallJsonSerializerOptions.GetTypeInfo(typeof(object))); 464JsonSerializer.Serialize(callRequest.Arguments, ToolCallJsonSerializerOptions.GetTypeInfo(typeof(IDictionary<string, object>)))))); 502argumentParser: static json => JsonSerializer.Deserialize(json,
AzureAIInferenceEmbeddingGenerator.cs (1)
176byte[] data = JsonSerializer.SerializeToUtf8Bytes(prop.Value, AIJsonUtilities.DefaultOptions.GetTypeInfo(typeof(object)));
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
AzureAIInferenceChatClientTests.cs (1)
409ResponseFormat = ChatResponseFormat.ForJsonSchema(JsonSerializer.Deserialize<JsonElement>("""
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (1)
70=> value is JsonElement e ? e : JsonSerializer.SerializeToElement(value, options);
Microsoft.Extensions.AI.Integration.Tests (4)
PromptBasedFunctionCallingChatClient.cs (4)
65var toolCallResultJson = JsonSerializer.Serialize(new ToolCallResult { Id = frc.CallId, Result = frc.Result }, _jsonOptions); 72var toolCallJson = JsonSerializer.Serialize(new { fcc.CallId, fcc.Name, fcc.Arguments }, _jsonOptions); 104var toolCallParsed = JsonSerializer.Deserialize<ToolCall>(toolCall, _jsonOptions); 161var toolDescriptorsJson = JsonSerializer.Serialize(tools.OfType<AIFunction>().Select(ToToolDescriptor), _jsonOptions);
Microsoft.Extensions.AI.Ollama (5)
OllamaChatClient.cs (5)
135var chunk = JsonSerializer.Deserialize(line, JsonContext.Default.OllamaChatResponse); 422Content = JsonSerializer.Serialize(new OllamaFunctionCallContent 426Arguments = JsonSerializer.SerializeToElement(fcc.Arguments, ToolCallJsonSerializerOptions.GetTypeInfo(typeof(IDictionary<string, object?>))), 434JsonElement jsonResult = JsonSerializer.SerializeToElement(frc.Result, ToolCallJsonSerializerOptions.GetTypeInfo(typeof(object))); 438Content = JsonSerializer.Serialize(new OllamaFunctionResultContent
Microsoft.Extensions.AI.Ollama.Tests (1)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (1)
70=> value is JsonElement e ? e : JsonSerializer.SerializeToElement(value, options);
Microsoft.Extensions.AI.OpenAI (13)
OpenAIModelMapper.ChatCompletion.cs (6)
44new(JsonSerializer.SerializeToUtf8Bytes( 336JsonSerializer.SerializeToUtf8Bytes(jsonSchema, OpenAIJsonContext.Default.JsonElement)), 353OpenAIChatToolJson openAiChatTool = JsonSerializer.Deserialize(chatTool.FunctionParameters.ToMemory().Span, OpenAIJsonContext.Default.OpenAIChatToolJson)!; 412JsonSerializer.SerializeToUtf8Bytes(tool, OpenAIJsonContext.Default.OpenAIChatToolJson)); 578argumentParser: static json => JsonSerializer.Deserialize(json, OpenAIJsonContext.Default.IDictionaryStringObject)!); 582argumentParser: static json => JsonSerializer.Deserialize(json, OpenAIJsonContext.Default.IDictionaryStringObject)!);
OpenAIModelMapper.ChatMessage.cs (3)
67result = JsonSerializer.Deserialize(textContent, AIJsonUtilities.DefaultOptions.GetTypeInfo(typeof(object))); 143result = JsonSerializer.Serialize(resultContent.Result, options.GetTypeInfo(typeof(object))); 170new(JsonSerializer.SerializeToUtf8Bytes(
OpenAIModelMappers.StreamingChatCompletion.cs (1)
40functionArgumentsUpdate: new(JsonSerializer.SerializeToUtf8Bytes(functionCallContent.Arguments, options.GetTypeInfo(typeof(IDictionary<string, object?>))))));
OpenAIRealtimeExtensions.cs (3)
46Parameters = new BinaryData(JsonSerializer.SerializeToUtf8Bytes( 121argumentParser: json => JsonSerializer.Deserialize(json, 127var resultJson = JsonSerializer.Serialize(result, jsonOptions.GetTypeInfo(typeof(object)));
Microsoft.Extensions.AI.OpenAI.Tests (1)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (1)
70=> value is JsonElement e ? e : JsonSerializer.SerializeToElement(value, options);
Microsoft.Extensions.AI.Tests (18)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (9)
20var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult))]) 81var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult))]); 171var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult))]); 181var responseFormatJsonSchema = JsonSerializer.Serialize(responseFormat.Schema, TestJsonSerializerContext.Default.JsonElement); 215var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult))]); 250var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(payload))]); 281var expectedCompletion = new ChatCompletion([new ChatMessage(ChatRole.Assistant, JsonSerializer.Serialize(expectedResult, jso))]); 321var resultDuplicatedJson = JsonSerializer.Serialize(expectedResult) + Environment.NewLine + JsonSerializer.Serialize(expectedResult);
ChatCompletion\DistributedCachingChatClientTest.cs (6)
740JsonSerializer.Serialize(expected.AdditionalProperties, TestJsonSerializerContext.Default.Options), 741JsonSerializer.Serialize(actual.AdditionalProperties, TestJsonSerializerContext.Default.Options)); 766JsonSerializer.Serialize(expectedFcc.Arguments, TestJsonSerializerContext.Default.Options), 767JsonSerializer.Serialize(actualFcc.Arguments, TestJsonSerializerContext.Default.Options)); 802JsonSerializer.Serialize(expectedFcc.Arguments, TestJsonSerializerContext.Default.Options), 803JsonSerializer.Serialize(actualFcc.Arguments, TestJsonSerializerContext.Default.Options));
Embeddings\DistributedCachingEmbeddingGeneratorTest.cs (2)
347JsonSerializer.Serialize(expected.AdditionalProperties, TestJsonSerializerContext.Default.Options), 348JsonSerializer.Serialize(actual.AdditionalProperties, TestJsonSerializerContext.Default.Options));
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (1)
70=> value is JsonElement e ? e : JsonSerializer.SerializeToElement(value, options);
Microsoft.Extensions.Caching.Hybrid (2)
Internal\DefaultJsonSerializerFactory.cs (2)
26return JsonSerializer.Deserialize<T>(ref reader)!; 36JsonSerializer.Serialize<T>(writer, value, JsonSerializerOptions.Default);
Microsoft.Extensions.Caching.Hybrid.Tests (2)
SampleUsage.cs (2)
176return JsonSerializer.Deserialize<T>(bytes)!; 182JsonSerializer.Serialize(ms, info);
Microsoft.JSInterop (8)
Infrastructure\DotNetDispatcher.cs (4)
64return JsonSerializer.Serialize(syncResult, jsRuntime.JsonSerializerOptions); 135var syncResultJson = JsonSerializer.Serialize(syncResult, jsRuntime.JsonSerializerOptions); 152var resultJson = JsonSerializer.Serialize(result, jsRuntime.JsonSerializerOptions); 246suppliedArgs[index] = JsonSerializer.Deserialize(ref reader, parameterType, jsRuntime.JsonSerializerOptions);
JSInProcessRuntime.cs (2)
20JsonSerializer.Serialize(args, JsonSerializerOptions), 32var result = JsonSerializer.Deserialize<TValue>(resultJson, JsonSerializerOptions)!;
JSRuntime.cs (2)
127JsonSerializer.Serialize(args, JsonSerializerOptions) : 247var result = JsonSerializer.Deserialize(ref jsonReader, resultType, JsonSerializerOptions);
Microsoft.JSInterop.Tests (56)
Infrastructure\ByteArrayJsonConverterTest.cs (15)
25var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 38var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 51var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 64var ex = Record.Exception(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 73var json = JsonSerializer.Serialize(expected); 76var deserialized = JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)!; 89var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 105var deserialized = JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)!; 121var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 137var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 153var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 169var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)); 188var deserialized = JsonSerializer.Deserialize<byte[]>(json, JsonSerializerOptions)!; 210var deserialized = JsonSerializer.Deserialize<byte[][]>(json, JsonSerializerOptions)!; 226var json = JsonSerializer.Serialize(byteArray, JsonSerializerOptions);
Infrastructure\DotNetDispatcherTest.cs (15)
91var result = JsonSerializer.Deserialize<TestDTO>(resultJson, jsRuntime.JsonSerializerOptions); 104var result = JsonSerializer.Deserialize<TestDTO>(resultJson, jsRuntime.JsonSerializerOptions); 121var argsJson = JsonSerializer.Serialize(new object[] 134var resultDto1 = JsonSerializer.Deserialize<TestDTO>(root[0].GetRawText(), jsRuntime.JsonSerializerOptions); 161var argsJson = JsonSerializer.Serialize(new object[] 269var argsJson = JsonSerializer.Serialize(new object[] { jsRuntime.LastInvocationAsyncHandle, true, testDTO }, jsRuntime.JsonSerializerOptions); 290var argsJson = JsonSerializer.Serialize(new object[] { jsRuntime.LastInvocationAsyncHandle, false, expected }, jsRuntime.JsonSerializerOptions); 306var argsJson = JsonSerializer.Serialize(new object[] { jsRuntime.LastInvocationAsyncHandle, false, null }, jsRuntime.JsonSerializerOptions); 323var argsJson = JsonSerializer.Serialize(new object[] { jsRuntime.LastInvocationAsyncHandle, true, testDTO }, jsRuntime.JsonSerializerOptions); 544var argsJson = JsonSerializer.Serialize(new object[] 565var argsJson = JsonSerializer.Serialize(new object[] 594var argsJson = JsonSerializer.Serialize(new object[] 610var result = JsonSerializer.Deserialize<SomePublicType.InvokableAsyncMethodResult>(resultJson, jsRuntime.JsonSerializerOptions); 633var argsJson = JsonSerializer.Serialize(new object[] 661var argsJson = JsonSerializer.Serialize(new object[] { }, jsRuntime.JsonSerializerOptions);
Infrastructure\DotNetObjectReferenceJsonConverterTest.cs (9)
23var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<DotNetObjectReference<TestModel>>(json, JsonSerializerOptions)); 37var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<DotNetObjectReference<TestModel>>(json, JsonSerializerOptions)); 52var ex = Record.Exception(() => JsonSerializer.Deserialize<DotNetObjectReference<TestModel>>(json, JsonSerializerOptions)); 67var ex = Record.Exception(() => JsonSerializer.Deserialize<DotNetObjectReference<TestModel>>(json, JsonSerializerOptions)); 82var deserialized = JsonSerializer.Deserialize<DotNetObjectReference<TestModel>>(json, JsonSerializerOptions)!; 102var deserialized = JsonSerializer.Deserialize<DotNetObjectReference<TestModel>[]>(json, JsonSerializerOptions)!; 123var deserialized = JsonSerializer.Deserialize<DotNetObjectReference<TestModel>>(json, JsonSerializerOptions)!; 137var json1 = JsonSerializer.Serialize(dotNetObjectRef, JsonSerializerOptions); 138var json2 = JsonSerializer.Serialize(dotNetObjectRef, JsonSerializerOptions);
Infrastructure\DotNetStreamReferenceJsonConverterTest.cs (3)
26var ex = Assert.Throws<NotSupportedException>(() => JsonSerializer.Deserialize<DotNetStreamReference>(json, JsonSerializerOptions)); 37var json = JsonSerializer.Serialize(streamRef, JsonSerializerOptions); 52var json = JsonSerializer.Serialize(streamRef, JsonSerializerOptions);
Infrastructure\JSObjectReferenceJsonConverterTest.cs (6)
27var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IJSObjectReference>(json, JsonSerializerOptions)); 38var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IJSObjectReference>(json, JsonSerializerOptions)); 49var ex = Record.Exception(() => JsonSerializer.Deserialize<IJSObjectReference>(json, JsonSerializerOptions)); 60var ex = Record.Exception(() => JsonSerializer.Deserialize<IJSObjectReference>(json, JsonSerializerOptions)); 72var deserialized = (JSObjectReference)JsonSerializer.Deserialize<IJSObjectReference>(json, JsonSerializerOptions)!; 85var json = JsonSerializer.Serialize((IJSObjectReference)jsObjectRef, JsonSerializerOptions);
Infrastructure\JSStreamReferenceJsonConverterTest.cs (8)
27var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IJSStreamReference>(json, JsonSerializerOptions)); 38var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IJSStreamReference>(json, JsonSerializerOptions)); 49var ex = Record.Exception(() => JsonSerializer.Deserialize<IJSStreamReference>(json, JsonSerializerOptions)); 60var ex = Record.Exception(() => JsonSerializer.Deserialize<IJSStreamReference>(json, JsonSerializerOptions)); 72var ex = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IJSStreamReference>(json, JsonSerializerOptions)); 85var deserialized = (JSStreamReference)JsonSerializer.Deserialize<IJSStreamReference>(json, JsonSerializerOptions)!; 101var deserialized = (JSStreamReference)JsonSerializer.Deserialize<IJSStreamReference>(json, JsonSerializerOptions)!; 115var json = JsonSerializer.Serialize((IJSStreamReference)jsObjectRef, JsonSerializerOptions);
Microsoft.Maui (4)
Handlers\HybridWebView\HybridWebViewHandler.cs (4)
170 var invokeData = JsonSerializer.Deserialize<JSInvokeMethodData>(invokeDataString, HybridWebViewHandlerJsonContext.Default.JSInvokeMethodData); 188 Result = JsonSerializer.Serialize(result), 205 contentBytes = System.Text.Encoding.UTF8.GetBytes(JsonSerializer.Serialize(dotNetInvokeResult)); 233 .Zip(invokeMethod.GetParameters(), (s, p) => s == null ? null : JsonSerializer.Deserialize(s, p.ParameterType))
Microsoft.Maui.Essentials (4)
Preferences\Preferences.uwp.cs (2)
253 PreferencesDictionary readPreferences = JsonSerializer.Deserialize(stream, PreferencesJsonSerializerContext.Default.PreferencesDictionary); 274 JsonSerializer.Serialize(stream, _preferences, PreferencesJsonSerializerContext.Default.PreferencesDictionary);
SecureStorage\SecureStorage.uwp.cs (2)
130 SecureStorageDictionary readPreferences = JsonSerializer.Deserialize(stream, SecureStorageJsonSerializerContext.Default.SecureStorageDictionary); 151 JsonSerializer.Serialize(stream, _secureStorage, SecureStorageJsonSerializerContext.Default.SecureStorageDictionary);
Microsoft.ML.AutoML (5)
AutoMLExperiment\AutoMLExperiment.cs (4)
272logger.Trace($"trial setting - {JsonSerializer.Serialize(trialSettings)}"); 299Exception thrown during Trial {trialSettings.TrialId} with configuration {JsonSerializer.Serialize(trialSettings)} 320logger.Trace($"trial fatal error - {JsonSerializer.Serialize(trialSettings)}, stop training"); 332logger.Trace($"trial cancelled - {JsonSerializer.Serialize(trialSettings)}, stop training");
Tuner\AutoZeroTuner.cs (1)
73var res = JsonSerializer.Deserialize<List<Config>>(json);
Microsoft.ML.AutoML.Interactive (4)
AutoMLMonitorKernelExtension.cs (3)
25Formatter.Register<Parameter>((parameter) => JsonSerializer.Serialize(parameter, new JsonSerializerOptions() { WriteIndented = true, })); 52var bestTrialParam = JsonSerializer.Serialize(monitor.BestTrial.TrialSettings.Parameter, new JsonSerializerOptions() { WriteIndented = true, }); 61var activeTrialParam = JsonSerializer.Serialize(monitor.ActiveTrial.Parameter, new JsonSerializerOptions() { WriteIndented = true, });
NotebookMonitor.cs (1)
47var activeRunParam = JsonSerializer.Serialize(result.TrialSettings.Parameter, new JsonSerializerOptions() { WriteIndented = false, });
Microsoft.ML.AutoML.SourceGenerator (5)
EstimatorTypeGenerator.cs (1)
28var flags = JsonSerializer.Deserialize<Dictionary<string, bool>>(json);
SearchSpaceGenerator.cs (1)
25var flags = JsonSerializer.Deserialize<Dictionary<string, bool>>(json);
SweepableEstimatorFactoryGenerator.cs (1)
25var flags = JsonSerializer.Deserialize<Dictionary<string, bool>>(json);
SweepableEstimatorGenerator.cs (1)
24var flags = JsonSerializer.Deserialize<Dictionary<string, bool>>(json);
Utils.cs (1)
17return JsonSerializer.Deserialize<EstimatorsContract>(json);
Microsoft.ML.AutoML.Tests (17)
AutoFeaturizerTests.cs (6)
50Approvals.Verify(JsonSerializer.Serialize(pipeline, _jsonSerializerOptions)); 62Approvals.Verify(JsonSerializer.Serialize(pipeline, _jsonSerializerOptions)); 74Approvals.Verify(JsonSerializer.Serialize(pipeline, _jsonSerializerOptions)); 86Approvals.Verify(JsonSerializer.Serialize(pipeline, _jsonSerializerOptions)); 97Approvals.Verify(JsonSerializer.Serialize(pipeline, _jsonSerializerOptions)); 113Approvals.Verify(JsonSerializer.Serialize(pipeline, _jsonSerializerOptions));
SweepableEstimatorPipelineTest.cs (1)
122Approvals.Verify(JsonSerializer.Serialize(defaultParam, _jsonSerializerOptions));
SweepableExtensionTest.cs (9)
84var json = JsonSerializer.Serialize(pipeline, _jsonSerializerOptions); 97var json = JsonSerializer.Serialize(pipeline, _jsonSerializerOptions); 110var json = JsonSerializer.Serialize(pipeline, _jsonSerializerOptions); 123var json = JsonSerializer.Serialize(pipeline, _jsonSerializerOptions); 137var json = JsonSerializer.Serialize(pipeline, _jsonSerializerOptions); 151var json = JsonSerializer.Serialize(pipeline, _jsonSerializerOptions); 164var json = JsonSerializer.Serialize(pipeline, _jsonSerializerOptions); 177var json = JsonSerializer.Serialize(pipeline, _jsonSerializerOptions); 192var json = JsonSerializer.Serialize(pipeline, _jsonSerializerOptions);
SweepablePipelineTests.cs (1)
70Approvals.Verify(JsonSerializer.Serialize(pipeline, _jsonSerializerOptions));
Microsoft.ML.GenAI.LLaMA (7)
LlamaConfig.cs (5)
52Llama3_1_8B_Instruct = JsonSerializer.Deserialize<LlamaConfig>(llama3_1_8b_content) ?? throw new ArgumentNullException(nameof(llama3_1_8b_content)); 53Llama3_1_70B_Instruct = JsonSerializer.Deserialize<LlamaConfig>(llama3_1_70b_content) ?? throw new ArgumentNullException(nameof(llama3_1_70b_content)); 54Llama3_1_405B_Instruct = JsonSerializer.Deserialize<LlamaConfig>(llama3_1_405b_content) ?? throw new ArgumentNullException(nameof(llama3_1_405b_content)); 55Llama3_2_1B_Instruct = JsonSerializer.Deserialize<LlamaConfig>(llama3_2_1b_content) ?? throw new ArgumentNullException(nameof(llama3_2_1b_content)); 56Llama_3_2_3B_Instruct = JsonSerializer.Deserialize<LlamaConfig>(llama3_2_3b_content) ?? throw new ArgumentNullException(nameof(llama3_2_3b_content));
LlamaForCausalLM.cs (2)
103var modelConfig = JsonSerializer.Deserialize<LlamaConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config)); 136var modelConfig = JsonSerializer.Deserialize<LlamaConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
Microsoft.ML.GenAI.Mistral (8)
Mistral_7B_0_3ChatTemplateBuilder.cs (3)
77var schemaPrompt = JsonSerializer.Serialize(schemas); 130var toolCallJson = JsonSerializer.Serialize(toolCallObjects); 152var toolCallResultJson = JsonSerializer.Serialize(toolCallResultObjects);
MistralCausalLMAgent.cs (2)
149var mistralToolCalls = JsonSerializer.Deserialize<List<MistralToolCall>>(json) ?? throw new InvalidOperationException("Failed to deserialize tool calls."); 151.Select(tc => new ToolCall(tc.Name!, JsonSerializer.Serialize(tc.Arguments)) { ToolCallId = this.GenerateToolCallId() });
MistralConfig.cs (1)
44Mistral_7B_Instruct_v0_3 = JsonSerializer.Deserialize<MistralConfig>(mistral7BInstructContent) ?? throw new ArgumentNullException(nameof(mistral7BInstructContent));
MistralForCausalLM.cs (2)
58var modelConfig = JsonSerializer.Deserialize<MistralConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config)); 86var modelConfig = JsonSerializer.Deserialize<MistralConfig>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
Microsoft.ML.GenAI.Phi (8)
Phi2\Config.cs (1)
45var phi2Config = JsonSerializer.Deserialize<Phi2Config>(phi2ConfigContent) ?? throw new ArgumentNullException(nameof(phi2ConfigContent));
Phi2\Phi2ForCasualLM.cs (1)
59var modelConfig = JsonSerializer.Deserialize<Phi2Config>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
Phi3\Config.cs (4)
50Phi3Mini4kInstruct = JsonSerializer.Deserialize<Phi3Config>(phi3Mini4kInstructContent) ?? throw new ArgumentNullException(nameof(phi3Mini4kInstructContent)); 51Phi3Mini128kInstruct = JsonSerializer.Deserialize<Phi3Config>(phi3Mini128kInstructContent) ?? throw new ArgumentNullException(nameof(phi3Mini128kInstructContent)); 52Phi3Medium4kInstruct = JsonSerializer.Deserialize<Phi3Config>(phi3Medium4kInstructContent) ?? throw new ArgumentNullException(nameof(phi3Medium4kInstructContent)); 53Phi3Medium128kInstruct = JsonSerializer.Deserialize<Phi3Config>(phi3Medium128kInstructContent) ?? throw new ArgumentNullException(nameof(phi3Medium128kInstructContent));
Phi3\Phi3ForCasualLM.cs (2)
60var modelConfig = JsonSerializer.Deserialize<Phi3Config>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config)); 88var modelConfig = JsonSerializer.Deserialize<Phi3Config>(File.ReadAllText(config)) ?? throw new ArgumentNullException(nameof(config));
Microsoft.ML.GenAI.Phi.Tests (1)
Phi3Tests.cs (1)
109var json = JsonSerializer.Serialize(sizeInMB, new JsonSerializerOptions { WriteIndented = true });
Microsoft.ML.GenAI.Samples (1)
Mistral\Mistral_7B_Instruct.cs (1)
76var mistralConfig = JsonSerializer.Deserialize<MistralConfig>(File.ReadAllText(Path.Combine(weightFolder, configName))) ?? throw new ArgumentNullException(nameof(configName));
Microsoft.ML.SearchSpace (24)
Converter\ChoiceOptionConverter.cs (2)
30var schema = JsonSerializer.Deserialize<Schema>(ref reader, options); 43JsonSerializer.Serialize(writer, schema, options);
Converter\NumericOptionConverter.cs (2)
39var schema = JsonSerializer.Deserialize<Schema>(ref reader, options); 81JsonSerializer.Serialize(writer, schema, options);
Converter\OptionConverter.cs (6)
20return JsonSerializer.Deserialize<SearchSpace>(ref reader, options); 29return JsonSerializer.Deserialize<ChoiceOption>(ref reader, options); 38return JsonSerializer.Deserialize<UniformNumericOption>(ref reader, options); 50JsonSerializer.Serialize(writer, ss, options); 54JsonSerializer.Serialize(writer, choiceOption, options); 58JsonSerializer.Serialize(writer, uniformNumericOption, options);
Converter\ParameterConverter.cs (4)
20var array = JsonSerializer.Deserialize<Dictionary<string, Parameter>>(ref reader, options).ToArray(); 23return Parameter.FromString(JsonSerializer.Deserialize<string>(ref reader, options)); 34return Parameter.FromDouble(JsonSerializer.Deserialize<double>(ref reader, options)); 56JsonSerializer.Serialize(writer, value.Value, options);
Converter\SearchSpaceConverter.cs (2)
18var optionKVPairs = JsonSerializer.Deserialize<Dictionary<string, OptionBase>>(ref reader, options); 25JsonSerializer.Serialize<IDictionary<string, OptionBase>>(value, options);
Parameter.cs (7)
286/// Cast <see cref="ParameterType"/> to <typeparamref name="T"/>. This method will return immediately if the underlying value is of type <typeparamref name="T"/>, otherwise it uses <see cref="JsonSerializer"/> to 297var json = JsonSerializer.Serialize(_value, _settings); 298return JsonSerializer.Deserialize<T>(json, _settings); 393var thisJson = JsonSerializer.Serialize(this); 394var otherJson = JsonSerializer.Serialize(other); 402var thisJson = JsonSerializer.Serialize(this); 426return JsonSerializer.Serialize(this);
SearchSpace.cs (1)
157var json = JsonSerializer.Serialize(parameter);
Microsoft.ML.SearchSpace.Tests (6)
ParameterTest.cs (5)
40var json = JsonSerializer.Serialize(parameter, _settings); 43parameter = JsonSerializer.Deserialize<Parameter>(json); 109var json = JsonSerializer.Serialize(parameter, _settings); 112parameter = JsonSerializer.Deserialize<Parameter>(json); 119json = JsonSerializer.Serialize(parameter, _settings);
SearchSpaceTest.cs (1)
303var json = JsonSerializer.Serialize(ss, _settings);
Microsoft.ML.Tokenizers (4)
Model\BPETokenizer.cs (2)
776? await JsonSerializer.DeserializeAsync(vocab, ModelSourceGenerationContext.Default.DictionaryStringSpanOrdinalKeyInt32, cancellationToken).ConfigureAwait(false) 777: JsonSerializer.Deserialize(vocab, ModelSourceGenerationContext.Default.DictionaryStringSpanOrdinalKeyInt32);
Model\CodeGenTokenizer.cs (1)
1770vocab = JsonSerializer.Deserialize(vocabularyStream, ModelSourceGenerationContext.Default.Vocabulary);
Model\EnglishRobertaTokenizer.cs (1)
184vocab = JsonSerializer.Deserialize(vocabularyStream, ModelSourceGenerationContext.Default.DictionaryStringSpanOrdinalKeyInt32);
Microsoft.ML.Tokenizers.Tests (7)
BpeTests.cs (1)
546File.WriteAllText(fileName, JsonSerializer.Serialize<Dictionary<string, int>>(dic), Encoding.UTF8);
TiktokenTests.cs (6)
220int[]? expected = JsonSerializer.Deserialize<int[]>(stream) as int[]; 293int[]? expected = JsonSerializer.Deserialize<int[]>(stream) as int[]; 329int[]? expected = JsonSerializer.Deserialize<int[]>(stream) as int[]; 348int[]? expected = JsonSerializer.Deserialize<int[]>(stream) as int[]; 367int[]? expected = JsonSerializer.Deserialize<int[]>(stream) as int[]; 386int[]? expected = JsonSerializer.Deserialize<int[]>(stream) as int[];
OrderProcessor (1)
OrderProcessingWorker.cs (1)
65var order = JsonSerializer.Deserialize<Order>(message.Span) ?? new Order() { Id = "fake" };
RunTests (1)
AssemblyScheduler.cs (1)
316var deserialized = JsonSerializer.Deserialize<List<string>>(File.ReadAllText(testListPath));
Shared (1)
JsonSchemaExporter\JsonSchemaExporter.cs (1)
717defaultValue = JsonSerializer.SerializeToNode(defaultVal, parameterTypeInfo);
Shared.Tests (4)
JsonSchemaExporter\JsonSchemaExporterTests.cs (1)
47JsonNode? instance = JsonSerializer.SerializeToNode(testData.Value, testData.Type, options);
JsonSchemaExporter\SchemaTestHelpers.cs (2)
69JsonSchema jsonSchema = JsonSerializer.Deserialize(schema, Context.Default.JsonSchema)!; 75JsonSerializer.Serialize(node, Context.Default.JsonNode!);
JsonSchemaExporter\TestTypes.cs (1)
781jObj["default"] = JsonSerializer.SerializeToNode(attr.Value);
System.Memory.Data (14)
System\BinaryData.cs (14)
79/// using <see cref="JsonSerializer"/>. 83/// <see cref="JsonSerializer"/>.</param> 91JsonSerializer.SerializeToUtf8Bytes(jsonSerializable, type ?? jsonSerializable?.GetType() ?? typeof(object), options), 98/// using <see cref="JsonSerializer"/> 102/// <see cref="JsonSerializer"/>.</param> 108JsonSerializer.SerializeToUtf8Bytes(jsonSerializable, type ?? jsonSerializable?.GetType() ?? typeof(object), context), 386/// the <see cref="JsonSerializer"/> 397=> new BinaryData(JsonSerializer.SerializeToUtf8Bytes(jsonSerializable, options), MediaTypeApplicationJson); 401/// the <see cref="JsonSerializer"/> 410=> new BinaryData(JsonSerializer.SerializeToUtf8Bytes(jsonSerializable, jsonTypeInfo), MediaTypeApplicationJson); 469/// <see cref="JsonSerializer"/>. 478=> JsonSerializer.Deserialize<T>(GetBytesWithTrimmedBom(), options); 482/// <see cref="JsonSerializer"/>. 489=> JsonSerializer.Deserialize(GetBytesWithTrimmedBom(), jsonTypeInfo);
System.Net.Http.Json (14)
System\Net\Http\Json\HttpClientJsonExtensions.cs (4)
20FromJsonAsyncCore(getMethod, client, requestUri, static (stream, options, cancellation) => JsonSerializer.DeserializeAsync(stream, options.type, options.options ?? JsonSerializerOptions.Web, cancellation), (type, options), cancellationToken); 25FromJsonAsyncCore(getMethod, client, requestUri, static (stream, options, cancellation) => JsonSerializer.DeserializeAsync<TValue>(stream, options ?? JsonSerializerOptions.Web, cancellation), options, cancellationToken); 28FromJsonAsyncCore(getMethod, client, requestUri, static (stream, options, cancellation) => JsonSerializer.DeserializeAsync(stream, options.type, options.context, cancellation), (type, context), cancellationToken); 31FromJsonAsyncCore(getMethod, client, requestUri, static (stream, options, cancellation) => JsonSerializer.DeserializeAsync(stream, options, cancellation), jsonTypeInfo, cancellationToken);
System\Net\Http\Json\HttpClientJsonExtensions.Get.AsyncEnumerable.cs (1)
169await foreach (TValue? value in JsonSerializer.DeserializeAsyncEnumerable<TValue>(
System\Net\Http\Json\HttpContentJsonExtensions.AsyncEnumerable.cs (1)
107await foreach (TValue? value in JsonSerializer.DeserializeAsyncEnumerable<TValue>(
System\Net\Http\Json\HttpContentJsonExtensions.cs (4)
94return await JsonSerializer.DeserializeAsync(contentStream, type, options ?? JsonSerializerOptions.Web, cancellationToken).ConfigureAwait(false); 104return await JsonSerializer.DeserializeAsync<T>(contentStream, options ?? JsonSerializerOptions.Web, cancellationToken).ConfigureAwait(false); 132return await JsonSerializer.DeserializeAsync(contentStream, type, context, cancellationToken).ConfigureAwait(false); 140return await JsonSerializer.DeserializeAsync(contentStream, jsonTypeInfo, cancellationToken).ConfigureAwait(false);
System\Net\Http\Json\JsonContent.cs (3)
119: JsonSerializer.SerializeAsync(targetStream, Value, _typeInfo, cancellationToken); 131await JsonSerializer.SerializeAsync(transcodingStream, Value, _typeInfo, cancellationToken).ConfigureAwait(false); 135JsonSerializer.Serialize(transcodingStream, Value, _typeInfo);
System\Net\Http\Json\JsonContent.netcoreapp.cs (1)
22JsonSerializer.Serialize(stream, Value, _typeInfo);
System.Text.Json (173)
src\libraries\System.Text.Json\Common\JsonNumberHandling.cs (1)
7/// Determines how <see cref="JsonSerializer"/> handles numbers when serializing and deserializing.
src\libraries\System.Text.Json\Common\JsonSourceGenerationMode.cs (2)
23/// This mode supports all <see cref="JsonSerializer"/> features. 31/// This mode supports only a subset of <see cref="JsonSerializer"/> features.
src\libraries\System.Text.Json\Common\JsonUnmappedMemberHandling.cs (1)
7/// Determines how <see cref="JsonSerializer"/> handles JSON properties that
System\Text\Json\Nodes\JsonNode.cs (2)
370[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 371[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Nodes\JsonValueOfTCustomized.cs (1)
27internal override JsonNode DeepCloneCore() => JsonSerializer.SerializeToNode(Value, _jsonTypeInfo)!;
System\Text\Json\Schema\JsonSchemaExporter.cs (2)
248propertySchema.DefaultValue = JsonSerializer.SerializeToNode(parameterInfo.DefaultValue, property.JsonTypeInfo); 293const string ValuesKeyword = JsonSerializer.ValuesPropertyName;
System\Text\Json\Serialization\Attributes\JsonNumberHandlingAttribute.cs (1)
23if (!JsonSerializer.IsValidNumberHandlingValue(handling))
System\Text\Json\Serialization\Attributes\JsonObjectCreationHandlingAttribute.cs (1)
45if (!JsonSerializer.IsValidCreationHandlingValue(handling))
System\Text\Json\Serialization\Converters\CastingConverter.cs (5)
45=> JsonSerializer.UnboxOnRead<T>(_sourceConverter.ReadAsObject(ref reader, typeToConvert, options)); 53value = JsonSerializer.UnboxOnRead<T>(sourceValue); 61=> JsonSerializer.UnboxOnRead<T>(_sourceConverter.ReadAsPropertyNameAsObject(ref reader, typeToConvert, options))!; 64=> JsonSerializer.UnboxOnRead<T>(_sourceConverter.ReadAsPropertyNameCoreAsObject(ref reader, typeToConvert, options))!; 73=> JsonSerializer.UnboxOnRead<T>(_sourceConverter.ReadNumberWithCustomHandlingAsObject(ref reader, handling, options))!;
System\Text\Json\Serialization\Converters\Collection\IAsyncEnumerableConverterFactory.cs (1)
15[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Converters\Collection\IEnumerableConverterFactory.cs (2)
18[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 25[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)]
System\Text\Json\Serialization\Converters\Collection\JsonCollectionConverter.cs (5)
146if (!JsonSerializer.TryReadMetadata(this, jsonTypeInfo, ref reader, ref state)) 154value = JsonSerializer.ResolveReferenceId<TCollection>(ref state); 177JsonSerializer.ValidateMetadataForArrayConverter(this, ref reader, ref state); 269Debug.Assert(JsonSerializer.IsMetadataPropertyName(reader.GetUnescapedSpan(), (state.Current.BaseJsonTypeInfo ?? jsonTypeInfo).PolymorphicTypeResolver), "should only be hit if metadata property."); 316state.Current.MetadataPropertyName = JsonSerializer.WriteMetadataForCollection(this, ref state, writer);
System\Text\Json\Serialization\Converters\Collection\JsonDictionaryConverter.cs (5)
168if (!JsonSerializer.TryReadMetadata(this, jsonTypeInfo, ref reader, ref state)) 176value = JsonSerializer.ResolveReferenceId<TDictionary>(ref state); 200JsonSerializer.ValidateMetadataForObjectConverter(ref state); 253if (JsonSerializer.IsMetadataPropertyName(propertyName, state.Current.BaseJsonTypeInfo.PolymorphicTypeResolver)) 358JsonSerializer.WriteMetadataForObject(this, ref state, writer);
System\Text\Json\Serialization\Converters\Collection\MemoryConverterFactory.cs (1)
10[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Converters\Collection\StackOrQueueConverterWithReflection.cs (4)
15[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 16[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 19[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 20[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Converters\Object\ObjectConverter.cs (2)
121JsonSerializer.TryHandleReferenceFromJsonElement(ref reader, ref state, element, out referenceValue)) 138JsonSerializer.TryHandleReferenceFromJsonNode(ref reader, ref state, node, out referenceValue))
System\Text\Json\Serialization\Converters\Object\ObjectConverterFactory.cs (2)
17[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 23[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)]
System\Text\Json\Serialization\Converters\Object\ObjectDefaultConverter.cs (10)
71if (!JsonSerializer.TryReadMetadata(this, jsonTypeInfo, ref reader, ref state)) 79value = JsonSerializer.ResolveReferenceId<T>(ref state); 102JsonSerializer.ValidateMetadataForObjectConverter(ref state); 107value = JsonSerializer.ResolveReferenceId<T>(ref state); 175ReadOnlySpan<byte> unescapedPropertyName = JsonSerializer.GetPropertyName(ref state, ref reader, options, out bool isAlreadyReadMetadataProperty); 184jsonPropertyInfo = JsonSerializer.LookupProperty( 292ReadOnlySpan<byte> unescapedPropertyName = JsonSerializer.GetPropertyName(ref state, ref reader, options, out bool isAlreadyReadMetadataProperty); 296JsonPropertyInfo jsonPropertyInfo = JsonSerializer.LookupProperty( 335JsonSerializer.WriteMetadataForObject(this, ref state, writer); 378JsonSerializer.WriteMetadataForObject(this, ref state, writer);
System\Text\Json\Serialization\Converters\Object\ObjectWithParameterizedConstructorConverter.cs (9)
106JsonSerializer.CreateExtensionDataProperty(obj, jsonPropertyInfo, options); 134if (!JsonSerializer.TryReadMetadata(this, jsonTypeInfo, ref reader, ref state)) 142value = JsonSerializer.ResolveReferenceId<T>(ref state); 180JsonSerializer.ValidateMetadataForObjectConverter(ref state); 185value = JsonSerializer.ResolveReferenceId<T>(ref state); 238JsonSerializer.CreateExtensionDataProperty(obj, jsonPropertyInfo, options); 302ReadOnlySpan<byte> unescapedPropertyName = JsonSerializer.GetPropertyName(ref state, ref reader, options, out bool isAlreadyReadMetadataProperty); 412ReadOnlySpan<byte> unescapedPropertyName = JsonSerializer.GetPropertyName(ref state, ref reader, options, out bool isAlreadyReadMetadataProperty); 607jsonPropertyInfo = JsonSerializer.LookupProperty(
System\Text\Json\Serialization\Converters\Object\ObjectWithParameterizedConstructorConverter.Large.Reflection.cs (4)
17[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 18[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 23[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 24[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Converters\Object\ObjectWithParameterizedConstructorConverter.Small.cs (2)
122[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 123[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Converters\Value\EnumConverterFactory.cs (1)
10[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Converters\Value\NullableConverterFactory.cs (1)
11[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Converters\Value\UnsupportedTypeConverterFactory.cs (1)
11[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\JsonConverter.cs (2)
234[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 235[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\JsonConverter.MetadataHandling.cs (1)
163if (canHaveIdMetadata && JsonSerializer.TryGetReferenceForValue(value, ref state, writer))
System\Text\Json\Serialization\JsonConverterOfT.cs (6)
79T valueOfT = JsonSerializer.UnboxOnWrite<T>(value)!; 86T valueOfT = JsonSerializer.UnboxOnWrite<T>(value)!; 93T valueOfT = JsonSerializer.UnboxOnWrite<T>(value)!; 99T valueOfT = JsonSerializer.UnboxOnWrite<T>(value)!; 105T valueOfT = JsonSerializer.UnboxOnWrite<T>(value)!; 112T valueOfT = JsonSerializer.UnboxOnWrite<T>(value)!;
System\Text\Json\Serialization\JsonSerializerOptions.Caching.cs (2)
51/// Returned metadata can be downcast to <see cref="JsonTypeInfo{T}"/> and used with the relevant <see cref="JsonSerializer"/> overloads. 79/// Returned metadata can be downcast to <see cref="JsonTypeInfo{T}"/> and used with the relevant <see cref="JsonSerializer"/> overloads.
System\Text\Json\Serialization\JsonSerializerOptions.Converters.cs (2)
13/// Provides options to be used with <see cref="JsonSerializer"/>. 48if (JsonSerializer.IsReflectionEnabledByDefault)
System\Text\Json\Serialization\JsonSerializerOptions.cs (18)
19/// Provides options to be used with <see cref="JsonSerializer"/>. 40[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 41[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 60[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 61[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 220/// The property will be populated automatically once used with one of the <see cref="JsonSerializer"/> methods. 450if (!JsonSerializer.IsValidNumberHandlingValue(value)) 476if (!JsonSerializer.IsValidCreationHandlingValue(value)) 668/// Determines how <see cref="JsonSerializer"/> handles JSON properties that 863/// it has been passed to one of the <see cref="JsonSerializer"/> methods, 894/// The <see cref="JsonSerializer.IsReflectionEnabledByDefault"/> feature switch has been turned off. 898/// the semantics of the <see cref="JsonSerializer"/> methods accepting <see cref="JsonSerializerOptions"/> parameters. 924[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 925[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 928if (JsonSerializer.IsReflectionEnabledByDefault) 1122[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 1123[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 1134TypeInfoResolver = JsonSerializer.IsReflectionEnabledByDefault
System\Text\Json\Serialization\Metadata\DefaultJsonTypeInfoResolver.Converters.cs (10)
18[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 19[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 92[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 93[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 131[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 132[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 142[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 143[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 173[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 174[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Metadata\DefaultJsonTypeInfoResolver.cs (8)
23[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 24[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 29[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 30[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 84[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 85[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 129[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 130[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Metadata\DefaultJsonTypeInfoResolver.Helpers.cs (24)
18[RequiresUnreferencedCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 19[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 44[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 45[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 94[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 95[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 138[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 139[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 198[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 199[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 220[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 221[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 284[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 285[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 320[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 321[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 408[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 409[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 449[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 450[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 468[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 469[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 492[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 493[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Metadata\JsonPolymorphismOptions.cs (1)
76get => _typeDiscriminatorPropertyName ?? JsonSerializer.TypePropertyName;
System\Text\Json\Serialization\Metadata\JsonPropertyInfo.cs (5)
211if (!JsonSerializer.IsValidCreationHandlingValue(value.Value)) 471[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 472[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 481Name is JsonSerializer.IdPropertyName or JsonSerializer.RefPropertyName)
System\Text\Json\Serialization\Metadata\JsonPropertyInfoOfT.cs (2)
142[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)] 143[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Metadata\JsonTypeInfo.cs (6)
335/// it has been passed to one of the <see cref="JsonSerializer"/> methods, 505if (value is not null && !JsonSerializer.IsValidNumberHandlingValue(value.Value)) 546if (value is not null && !JsonSerializer.IsValidUnmappedMemberHandlingValue(value.Value)) 590if (value is not null && !JsonSerializer.IsValidCreationHandlingValue(value.Value)) 1018[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 1019[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)]
System\Text\Json\Serialization\Metadata\JsonTypeInfoOfT.WriteHelpers.cs (8)
69int flushThreshold = (int)(Options.DefaultBufferSize * JsonSerializer.FlushThreshold); 79int flushThreshold = (int)(4 * PipeOptions.Default.MinimumSegmentSize * JsonSerializer.FlushThreshold); 307state.FlushThreshold = (int)(bufferWriter.Capacity * JsonSerializer.FlushThreshold); 332=> Serialize(writer, JsonSerializer.UnboxOnWrite<T>(rootValue), rootValue); 335=> SerializeAsync(pipeWriter, JsonSerializer.UnboxOnWrite<T>(rootValue), flushThreshold, cancellationToken, rootValue); 338=> SerializeAsync(utf8Json, JsonSerializer.UnboxOnWrite<T>(rootValue), cancellationToken, rootValue); 341=> SerializeAsync(utf8Json, JsonSerializer.UnboxOnWrite<T>(rootValue), cancellationToken, rootValue); 344=> Serialize(utf8Json, JsonSerializer.UnboxOnWrite<T>(rootValue), rootValue);
System\Text\Json\Serialization\Metadata\PolymorphicTypeResolver.cs (2)
81if (!propertyName.Equals(JsonSerializer.TypePropertyName, StringComparison.Ordinal)) 86if ((JsonSerializer.GetMetadataPropertyName(utf8EncodedName, resolver: null) & ~MetadataPropertyName.Type) != 0)
System\Text\Json\Serialization\Metadata\ReflectionEmitCachingMemberAccessor.cs (2)
16[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 17[RequiresUnreferencedCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Metadata\ReflectionEmitMemberAccessor.cs (2)
13[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 14[RequiresUnreferencedCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\Metadata\ReflectionMemberAccessor.cs (2)
11[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)] 12[RequiresUnreferencedCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
System\Text\Json\Serialization\ReferenceHandler.cs (1)
9/// This class defines how the <see cref="JsonSerializer"/> deals with references on serialization and deserialization.
System\Text\Json\Serialization\ReferenceHandlerOfT.cs (1)
7/// This class defines how the <see cref="JsonSerializer"/> deals with references on serialization and deserialization.
System\Text\Json\Serialization\ReferenceResolver.cs (1)
7/// This class defines how the <see cref="JsonSerializer"/> deals with references on serialization and deserialization.
System\Text\Json\ThrowHelper.Serialization.cs (1)
801MetadataPropertyName name = JsonSerializer.GetMetadataPropertyName(propertyName, state.Current.BaseJsonTypeInfo.PolymorphicTypeResolver);
System.Windows.Forms (7)
System\Windows\Forms\Nrbf\WinFormsSerializationRecordExtensions.cs (1)
97@object = JsonSerializer.Deserialize<T>(byteData.GetArray());
System\Windows\Forms\OLE\Clipboard.cs (2)
537/// The default behavior of <see cref="JsonSerializer"/> is used to serialize the data. 543/// for more details on default <see cref="JsonSerializer"/> behavior.
System\Windows\Forms\OLE\DataObject.cs (3)
132/// The default behavior of <see cref="JsonSerializer"/> is used to serialize the data. 138/// for more details on default <see cref="JsonSerializer"/> behavior. 173: new JsonData<T>() { JsonBytes = JsonSerializer.SerializeToUtf8Bytes(data) };
System\Windows\Forms\OLE\JsonData.cs (1)
120result = JsonSerializer.Deserialize<T>(JsonBytes);
System.Windows.Forms.Tests (9)
System\Windows\Forms\BinaryFormat\WinFormsBinaryFormattedObjectTests.cs (3)
39JsonBytes = JsonSerializer.SerializeToUtf8Bytes(testData) 61JsonBytes = JsonSerializer.SerializeToUtf8Bytes(testData) 89result = JsonSerializer.Deserialize<SimpleTestData>(JsonBytes);
System\Windows\Forms\ClipboardTests.cs (6)
1061JsonSerializer.Deserialize(byteData.GetArray(), typeof(SimpleTestData)).Should().BeEquivalentTo(testData); 1073byte[] serialized = JsonSerializer.SerializeToUtf8Bytes(font); 1074Action a1 = () => JsonSerializer.Deserialize<Font>(serialized); 1109JsonSerializer.Deserialize(jsonBytes, typeof(SimpleTestData)).Should().BeEquivalentTo(data); 1133return JsonSerializer.Deserialize<T>(_formatToJson[format]); 1148_formatToJson.Add(format, JsonSerializer.SerializeToUtf8Bytes(data));
Templates.Blazor.Tests (2)
BlazorWasmTemplateTest.cs (1)
122var serviceWorkerAssetsManifestVersion = JsonSerializer.Deserialize<string>(serviceWorkerAssetsManifestVersionJson);
src\ProjectTemplates\Shared\DevelopmentCertificate.cs (1)
27var certificateAttributes = JsonSerializer.Deserialize<CertificateAttributes>(file) ??
Templates.Blazor.WebAssembly.Auth.Tests (1)
src\ProjectTemplates\Shared\DevelopmentCertificate.cs (1)
27var certificateAttributes = JsonSerializer.Deserialize<CertificateAttributes>(file) ??
Templates.Blazor.WebAssembly.Tests (1)
src\ProjectTemplates\Shared\DevelopmentCertificate.cs (1)
27var certificateAttributes = JsonSerializer.Deserialize<CertificateAttributes>(file) ??
Templates.Mvc.Tests (1)
src\ProjectTemplates\Shared\DevelopmentCertificate.cs (1)
27var certificateAttributes = JsonSerializer.Deserialize<CertificateAttributes>(file) ??
Templates.Tests (1)
src\ProjectTemplates\Shared\DevelopmentCertificate.cs (1)
27var certificateAttributes = JsonSerializer.Deserialize<CertificateAttributes>(file) ??
TestDiscoveryWorker (1)
Program.cs (1)
94await JsonSerializer.SerializeAsync(fileStream, testsToWrite).ConfigureAwait(false);
TestProject.AppHost (1)
TestProgram.cs (1)
173await Console.Out.WriteLineAsync("$ENDPOINTS: " + JsonSerializer.Serialize(root, JsonSerializerOptions.Default));
Wasm.Performance.Driver (2)
BenchmarkResultsStartup.cs (1)
22var result = await JsonSerializer.DeserializeAsync<BenchmarkResult>(context.Request.Body, new JsonSerializerOptions
Program.cs (1)
255builder.AppendLine(JsonSerializer.Serialize(output));