9 instantiations of JsonElement
Microsoft.AspNetCore.Components.WebAssembly.Server (1)
Microsoft.Build (1)
System.Text.Json (7)
733 references to JsonElement
Aspire.Hosting.PostgreSQL.Tests (1)
Aspire.Hosting.Tests (1)
Diagnostics.FunctionalTests (2)
dotnet-openapi (1)
dotnet-user-jwts (8)
JwtBearerSample (1)
Microsoft.AspNetCore.Authentication (4)
Microsoft.AspNetCore.Authentication.OAuth (24)
Microsoft.AspNetCore.Authentication.OpenIdConnect (1)
Microsoft.AspNetCore.Authentication.Test (2)
Microsoft.AspNetCore.Authentication.Twitter (5)
Microsoft.AspNetCore.Components.Endpoints.Tests (15)
Microsoft.AspNetCore.Components.Server (6)
Microsoft.AspNetCore.Components.Server.Tests (2)
Microsoft.AspNetCore.Components.Web (36)
Microsoft.AspNetCore.Components.Web.Tests (51)
Microsoft.AspNetCore.Components.WebAssembly (5)
Microsoft.AspNetCore.Components.WebAssembly.Server (12)
Microsoft.AspNetCore.Components.WebView (6)
IpcCommon.cs (6)
19public static bool TryDeserializeIncoming(string message, out IncomingMessageType messageType, out ArraySegment<JsonElement> args)
22public static bool TryDeserializeOutgoing(string message, out OutgoingMessageType messageType, out ArraySegment<JsonElement> args)
37private static bool TryDeserialize<T>(string message, out T messageType, out ArraySegment<JsonElement> args)
44var parsed = (JsonElement[])JsonSerializer.Deserialize(messageAfterPrefix, typeof(JsonElement[]), JsonSerializerOptionsProvider.Options);
46args = new ArraySegment<JsonElement>(parsed, 1, parsed.Length - 1);
Microsoft.AspNetCore.Diagnostics.Tests (10)
Microsoft.AspNetCore.Grpc.JsonTranscoding (2)
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (7)
Microsoft.AspNetCore.Http.Abstractions.Tests (1)
Microsoft.AspNetCore.Http.Extensions (1)
Microsoft.AspNetCore.Http.Extensions.Tests (3)
Microsoft.AspNetCore.Identity.FunctionalTests (106)
Microsoft.AspNetCore.Mvc.FunctionalTests (3)
Microsoft.AspNetCore.Mvc.ViewFeatures (6)
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (1)
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (1)
Microsoft.AspNetCore.SignalR.Tests (2)
Microsoft.Build (3)
Microsoft.CodeAnalysis.EditorFeatures (8)
Microsoft.CodeAnalysis.ExternalAccess.Razor (6)
Microsoft.CodeAnalysis.ExternalAccess.Xaml (2)
Microsoft.CodeAnalysis.Features (1)
Microsoft.CodeAnalysis.LanguageServer.Protocol (28)
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (4)
Microsoft.CodeAnalysis.LanguageServer.UnitTests (2)
Microsoft.CodeAnalysis.Workspaces.MSBuild (2)
Microsoft.CommonLanguageServerProtocol.Framework.Package (6)
Microsoft.DotNet.Arcade.Sdk (3)
Microsoft.Extensions.AI (15)
Microsoft.Extensions.AI.Abstractions (19)
Microsoft.Extensions.AI.Abstractions.Tests (46)
Utilities\AIJsonUtilitiesTests.cs (22)
54JsonElement expected = JsonDocument.Parse("""
77JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(MyPoco), serializerOptions: JsonSerializerOptions.Default);
79Assert.True(JsonElement.DeepEquals(expected, actual));
85JsonElement expected = JsonDocument.Parse("""
116JsonElement actual = AIJsonUtilities.CreateJsonSchema(
124Assert.True(JsonElement.DeepEquals(expected, actual));
130JsonElement expected = JsonDocument.Parse("""
167JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(MyPoco), serializerOptions: JsonSerializerOptions.Default, inferenceOptions: inferenceOptions);
169Assert.True(JsonElement.DeepEquals(expected, actual));
175JsonElement expected = JsonDocument.Parse("""
195JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(PocoWithTypesWithOpenAIUnsupportedKeywords), serializerOptions: JsonSerializerOptions.Default);
197Assert.True(JsonElement.DeepEquals(expected, actual));
220JsonElement generatedSchema = Assert.IsType<JsonElement>(param.Schema);
222JsonElement resolvedSchema;
224Assert.True(JsonElement.DeepEquals(generatedSchema, resolvedSchema));
230JsonElement expected = JsonDocument.Parse("""
242JsonElement actualSchema = Assert.IsType<JsonElement>(param.Schema);
243Assert.True(JsonElement.DeepEquals(expected, actualSchema));
260JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(object));
279JsonElement schema = AIJsonUtilities.CreateJsonSchema(testData.Type, serializerOptions: options, inferenceOptions: createOptions);
Microsoft.Extensions.AI.AzureAIInference (3)
Microsoft.Extensions.AI.AzureAIInference.Tests (6)
Microsoft.Extensions.AI.Integration.Tests (1)
Microsoft.Extensions.AI.Ollama (9)
Microsoft.Extensions.AI.Ollama.Tests (5)
Microsoft.Extensions.AI.OpenAI (10)
Microsoft.Extensions.AI.OpenAI.Tests (8)
Microsoft.Extensions.AI.Tests (6)
Microsoft.Extensions.Configuration.Json (4)
Microsoft.JSInterop.Tests (3)
Microsoft.ML.GenAI.Phi (4)
Negotiate.Client (2)
OpenIdConnectSample (2)
Shared (1)
Shared.Tests (4)
SocialSample (2)
System.Text.Json (182)
System\Text\Json\Document\JsonElement.cs (27)
62public JsonElement this[int index]
107/// Gets a <see cref="JsonElement"/> representing the value of a required property identified
118/// A <see cref="JsonElement"/> representing the value of the requested property.
133public JsonElement GetProperty(string propertyName)
140if (TryGetProperty(propertyName, out JsonElement property))
149/// Gets a <see cref="JsonElement"/> representing the value of a required property identified
164/// A <see cref="JsonElement"/> representing the value of the requested property.
176public JsonElement GetProperty(ReadOnlySpan<char> propertyName)
178if (TryGetProperty(propertyName, out JsonElement property))
187/// Gets a <see cref="JsonElement"/> representing the value of a required property identified
204/// A <see cref="JsonElement"/> representing the value of the requested property.
216public JsonElement GetProperty(ReadOnlySpan<byte> utf8PropertyName)
218if (TryGetProperty(utf8PropertyName, out JsonElement property))
256public bool TryGetProperty(string propertyName, out JsonElement value)
293public bool TryGetProperty(ReadOnlySpan<char> propertyName, out JsonElement value)
329public bool TryGetProperty(ReadOnlySpan<byte> utf8PropertyName, out JsonElement value)
1243/// Compares the values of two <see cref="JsonElement"/> values for equality, including the values of all descendant elements.
1245/// <param name="element1">The first <see cref="JsonElement"/> to compare.</param>
1246/// <param name="element2">The second <see cref="JsonElement"/> to compare.</param>
1263public static bool DeepEquals(JsonElement element1, JsonElement element2)
1309foreach (JsonElement e1 in element1.EnumerateArray())
1373Dictionary<string, ValueQueue<JsonElement>> properties2 = new(capacity: remainingProps, StringComparer.Ordinal);
1378ref ValueQueue<JsonElement> values = ref CollectionsMarshal.GetValueRefOrAddDefault(properties2, prop2.Name, out bool _);
1393ref ValueQueue<JsonElement> values = ref CollectionsMarshal.GetValueRefOrAddDefault(properties2, prop.Name, out bool exists);
1397if (!exists || !values.TryDequeue(out JsonElement value) || !DeepEquals(prop.Value, value))
1697public JsonElement Clone()
System\Text\Json\Serialization\JsonSerializer.Write.Element.cs (19)
14/// Converts the provided value into a <see cref="JsonElement"/>.
17/// <returns>A <see cref="JsonElement"/> representation of the JSON value.</returns>
26public static JsonElement SerializeToElement<TValue>(TValue value, JsonSerializerOptions? options = null)
33/// Converts the provided value into a <see cref="JsonElement"/>.
35/// <returns>A <see cref="JsonElement"/> representation of the value.</returns>
51public static JsonElement SerializeToElement(object? value, Type inputType, JsonSerializerOptions? options = null)
59/// Converts the provided value into a <see cref="JsonElement"/>.
62/// <returns>A <see cref="JsonElement"/> representation of the value.</returns>
68public static JsonElement SerializeToElement<TValue>(TValue value, JsonTypeInfo<TValue> jsonTypeInfo)
80/// Converts the provided value into a <see cref="JsonElement"/>.
82/// <returns>A <see cref="JsonElement"/> representation of the value.</returns>
91public static JsonElement SerializeToElement(object? value, JsonTypeInfo jsonTypeInfo)
103/// Converts the provided value into a <see cref="JsonElement"/>.
105/// <returns>A <see cref="JsonElement"/> representation of the value.</returns>
120public static JsonElement SerializeToElement(object? value, Type inputType, JsonSerializerContext context)
132private static JsonElement WriteElement<TValue>(in TValue value, JsonTypeInfo<TValue> jsonTypeInfo)
142return JsonElement.ParseValue(output.WrittenMemory.Span, options.GetDocumentOptions());
150private static JsonElement WriteElementAsObject(object? value, JsonTypeInfo jsonTypeInfo)
160return JsonElement.ParseValue(output.WrittenMemory.Span, options.GetDocumentOptions());
Templates.Blazor.Tests (2)
Templates.Blazor.WebAssembly.Auth.Tests (2)
Templates.Blazor.WebAssembly.Tests (2)
Templates.Mvc.Tests (2)
Templates.Tests (2)