9 instantiations of JsonElement
Microsoft.Build (1)
System.Text.Json (8)
1146 references to JsonElement
aspire (97)
DotNet\DotNetCliRunner.cs (13)
245var rootElement = jsonDocument.RootElement;
247if (!rootElement.TryGetProperty("Properties", out var properties))
252if (!properties.TryGetProperty("IsAspireHost", out var isAspireHostElement))
262if (rootElement.TryGetProperty("Items", out var items))
265if (items.TryGetProperty("PackageReference", out var packageReferences))
267foreach (var packageRef in packageReferences.EnumerateArray())
269if (packageRef.TryGetProperty("Identity", out var identity) &&
271packageRef.TryGetProperty("Version", out var version))
280if (aspireHostingVersion == null && items.TryGetProperty("AspireProjectOrPackageReference", out var aspireProjectOrPackageReferences))
282foreach (var aspireRef in aspireProjectOrPackageReferences.EnumerateArray())
284if (aspireRef.TryGetProperty("Identity", out var identity) &&
286aspireRef.TryGetProperty("Version", out var version))
296if (aspireHostingVersion == null && properties.TryGetProperty("AspireHostingSDKVersion", out var aspireHostingSdkVersionElement))
Npm\SigstoreNpmProvenanceChecker.cs (10)
268if (predicate.TryGetProperty("buildDefinition", out var buildDefinition) &&
271if (buildDefinition.TryGetProperty("buildType", out var buildTypeElement) &&
277if (buildDefinition.TryGetProperty("externalParameters", out var extParams) &&
279extParams.TryGetProperty("workflow", out var workflow) &&
282if (workflow.TryGetProperty("repository", out var repoEl) &&
288if (workflow.TryGetProperty("path", out var pathEl) &&
294if (workflow.TryGetProperty("ref", out var refEl) &&
302if (predicate.TryGetProperty("runDetails", out var runDetails) &&
304runDetails.TryGetProperty("builder", out var builder) &&
307if (builder.TryGetProperty("id", out var idEl) &&
Aspire.Azure.Npgsql (6)
Aspire.Azure.Npgsql.EntityFrameworkCore.PostgreSQL (6)
Aspire.Cli.Tests (32)
Aspire.Dashboard (3)
Aspire.Dashboard.Tests (7)
Aspire.Hosting (15)
Dcp\DcpLogParser.cs (6)
143var root = doc.RootElement;
158("Cmd", root.TryGetProperty("Cmd", out var cmdProp) ? cmdProp.GetString() : null),
159("Args", root.TryGetProperty("Args", out var argsProp) ? argsProp.ToString() : null),
160("ContainerName", root.TryGetProperty("ContainerName", out var containerNameProp) ? containerNameProp.GetString() : null),
161("ContainerId", root.TryGetProperty("ContainerID", out var containerIdProp) ? containerIdProp.GetString() : null),
162("Error", root.TryGetProperty("error", out var errorProp) ? errorProp.GetString() : null)
Aspire.Hosting.JavaScript (2)
Aspire.Hosting.Maui (3)
Aspire.Hosting.OpenAI (3)
Aspire.Hosting.PostgreSQL.Tests (1)
Aspire.Hosting.Seq.Tests (2)
Aspire.Hosting.Tests (39)
Aspire.Templates.Tests (2)
dotnet (17)
dotnet-sourcelink (1)
dotnet-user-jwts (8)
ILCompiler.Compiler (1)
ILCompiler.ReadyToRun (4)
Infrastructure.Tests (11)
Microsoft.AspNetCore.Authentication (4)
Microsoft.AspNetCore.Authentication.OAuth (24)
Microsoft.AspNetCore.Components.Endpoints (19)
src\aspnetcore\src\Components\Shared\src\RenderFragmentSerializer.cs (6)
239builder.SetKey(node.Key is JsonElement je ? ConvertTypedValue(je, node.KeyTypeAssembly!, node.KeyTypeName!, jsonOptions, typeCache) : node.Key);
266builder.SetKey(node.Key is JsonElement je ? ConvertTypedValue(je, node.KeyTypeAssembly!, node.KeyTypeName!, jsonOptions, typeCache) : node.Key);
287var value = attr.Value is JsonElement je
315JsonElement je => JsonSerializer.Deserialize<SerializedRenderFragment>(je.GetRawText(), jsonOptions),
322return attr.Value is JsonElement json ? ConvertTypedValue(json, attr.TypeAssembly!, attr.TypeName!, jsonOptions, typeCache) : attr.Value;
326private static object? ConvertTypedValue(JsonElement json, string assemblyName, string typeName, JsonSerializerOptions? jsonOptions, ComponentParametersTypeCache typeCache)
Microsoft.AspNetCore.Components.Server (14)
src\aspnetcore\src\Components\Shared\src\RenderFragmentSerializer.cs (6)
239builder.SetKey(node.Key is JsonElement je ? ConvertTypedValue(je, node.KeyTypeAssembly!, node.KeyTypeName!, jsonOptions, typeCache) : node.Key);
266builder.SetKey(node.Key is JsonElement je ? ConvertTypedValue(je, node.KeyTypeAssembly!, node.KeyTypeName!, jsonOptions, typeCache) : node.Key);
287var value = attr.Value is JsonElement je
315JsonElement je => JsonSerializer.Deserialize<SerializedRenderFragment>(je.GetRawText(), jsonOptions),
322return attr.Value is JsonElement json ? ConvertTypedValue(json, attr.TypeAssembly!, attr.TypeName!, jsonOptions, typeCache) : attr.Value;
326private static object? ConvertTypedValue(JsonElement json, string assemblyName, string typeName, JsonSerializerOptions? jsonOptions, ComponentParametersTypeCache typeCache)
Microsoft.AspNetCore.Components.Web (36)
Microsoft.AspNetCore.Http.Extensions (10)
Microsoft.AspNetCore.Identity (44)
_generated\31\IdentityJsonSerializerContext.PublicKeyCredentialAuthenticatorAssertionResponse.g.cs (6)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.AspNetCore.Identity.PublicKeyCredential<global::Microsoft.AspNetCore.Identity.AuthenticatorAssertionResponse>(){ Id = (global::Microsoft.AspNetCore.Identity.BufferSource)args[0], Type = (string)args[1], ClientExtensionResults = (global::System.Text.Json.JsonElement)args[2], Response = (global::Microsoft.AspNetCore.Identity.AuthenticatorAssertionResponse)args[3] },
99var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement>
114AttributeProviderFactory = static () => typeof(global::Microsoft.AspNetCore.Identity.PublicKeyCredential<global::Microsoft.AspNetCore.Identity.AuthenticatorAssertionResponse>).GetProperty("ClientExtensionResults", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement), global::System.Array.Empty<global::System.Type>(), null),
117properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement>(options, info2);
229ParameterType = typeof(global::System.Text.Json.JsonElement),
253public static extern void __set_PublicKeyCredentialAuthenticatorAssertionResponse_ClientExtensionResults(global::Microsoft.AspNetCore.Identity.PublicKeyCredential<TResponse> obj, global::System.Text.Json.JsonElement value);
_generated\32\IdentityJsonSerializerContext.PublicKeyCredentialAuthenticatorAttestationResponse.g.cs (6)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.AspNetCore.Identity.PublicKeyCredential<global::Microsoft.AspNetCore.Identity.AuthenticatorAttestationResponse>(){ Id = (global::Microsoft.AspNetCore.Identity.BufferSource)args[0], Type = (string)args[1], ClientExtensionResults = (global::System.Text.Json.JsonElement)args[2], Response = (global::Microsoft.AspNetCore.Identity.AuthenticatorAttestationResponse)args[3] },
99var info2 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Text.Json.JsonElement>
114AttributeProviderFactory = static () => typeof(global::Microsoft.AspNetCore.Identity.PublicKeyCredential<global::Microsoft.AspNetCore.Identity.AuthenticatorAttestationResponse>).GetProperty("ClientExtensionResults", InstanceMemberBindingFlags, null, typeof(global::System.Text.Json.JsonElement), global::System.Array.Empty<global::System.Type>(), null),
117properties[2] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Text.Json.JsonElement>(options, info2);
229ParameterType = typeof(global::System.Text.Json.JsonElement),
253public static extern void __set_PublicKeyCredentialAuthenticatorAttestationResponse_ClientExtensionResults(global::Microsoft.AspNetCore.Identity.PublicKeyCredential<TResponse> obj, global::System.Text.Json.JsonElement value);
Microsoft.AspNetCore.Mvc.ViewFeatures (6)
Microsoft.Build (3)
Microsoft.CodeAnalysis.Features (1)
Microsoft.CodeAnalysis.Workspaces.MSBuild (2)
Microsoft.CodeAnalysis.Workspaces.MSBuild.Contracts (2)
Microsoft.Deployment.DotNet.Releases (34)
Microsoft.Diagnostics.DataContractReader (28)
_generated\0\ContractDescriptorContext.ContractDescriptor.g.cs (3)
173var info6 = new global::System.Text.Json.Serialization.Metadata.JsonPropertyInfoValues<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>
188AttributeProviderFactory = static () => typeof(global::Microsoft.Diagnostics.DataContractReader.ContractDescriptorParser.ContractDescriptor).GetProperty("Extras", InstanceMemberBindingFlags, null, typeof(global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>), global::System.Array.Empty<global::System.Type>(), null),
191properties[6] = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreatePropertyInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>(options, info6);
_generated\7\ContractDescriptorContext.DictionaryStringJsonElement.g.cs (13)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>? _DictionaryStringJsonElement;
21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>> DictionaryStringJsonElement
24get => _DictionaryStringJsonElement ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>)Options.GetTypeInfo(typeof(global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>));
27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>> Create_DictionaryStringJsonElement(global::System.Text.Json.JsonSerializerOptions options)
29if (!TryGetTypeInfoForRuntimeCustomConverter<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>> jsonTypeInfo))
31var info = new global::System.Text.Json.Serialization.Metadata.JsonCollectionInfoValues<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>>
33ObjectCreator = () => new global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>(),
37jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateDictionaryInfo<global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>, string, global::System.Text.Json.JsonElement>(options, info);
47private void DictionaryStringJsonElementSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::System.Collections.Generic.Dictionary<string, global::System.Text.Json.JsonElement>? value)
57foreach (global::System.Collections.Generic.KeyValuePair<string, global::System.Text.Json.JsonElement> entry in value)
Microsoft.DotNet.Arcade.Sdk (3)
Microsoft.DotNet.ProjectTools (6)
Microsoft.Extensions.AI (9)
Microsoft.Extensions.AI.Abstractions (50)
Functions\AIFunctionFactory.cs (24)
82/// invocation directly if the object is already of a compatible type. Otherwise, if the argument is a <see cref="JsonElement"/>, <see cref="JsonDocument"/>,
94/// By default, return values are serialized to <see cref="JsonElement"/> using <paramref name="options"/>'s
155/// invocation directly if the object is already of a compatible type. Otherwise, if the argument is a <see cref="JsonElement"/>, <see cref="JsonDocument"/>,
167/// Return values are serialized to <see cref="JsonElement"/> using <paramref name="serializerOptions"/> if provided,
240/// invocation directly if the object is already of a compatible type. Otherwise, if the argument is a <see cref="JsonElement"/>, <see cref="JsonDocument"/>,
252/// By default, return values are serialized to <see cref="JsonElement"/> using <paramref name="options"/>'s
320/// invocation directly if the object is already of a compatible type. Otherwise, if the argument is a <see cref="JsonElement"/>, <see cref="JsonDocument"/>,
332/// Return values are serialized to <see cref="JsonElement"/> using <paramref name="serializerOptions"/> if provided,
374/// Return values are serialized to <see cref="JsonElement"/> using <paramref name="options"/>'s
377/// <see cref="AIFunctionFactoryOptions.SerializerOptions"/>. If the argument is a <see cref="JsonElement"/>,
418/// invocation directly if the object is already of a compatible type. Otherwise, if the argument is a <see cref="JsonElement"/>, <see cref="JsonDocument"/>,
430/// By default, return values are serialized to <see cref="JsonElement"/> using <paramref name="options"/>'s
464JsonElement jsonSchema,
465JsonElement? returnJsonSchema = null) =>
473string name, string description, JsonElement jsonSchema, JsonElement? returnJsonSchema) :
478public override JsonElement JsonSchema => jsonSchema;
479public override JsonElement? ReturnJsonSchema => returnJsonSchema;
555public override JsonElement JsonSchema => FunctionDescriptor.JsonSchema;
556public override JsonElement? ReturnJsonSchema => FunctionDescriptor.ReturnJsonSchema;
723public JsonElement JsonSchema { get; }
724public JsonElement? ReturnJsonSchema { get; }
843JsonElement element => JsonSerializer.Deserialize(element, typeInfo),
1071return JsonElement.ParseValue(ref reader);
Microsoft.Extensions.AI.Abstractions.Tests (111)
Utilities\AIJsonUtilitiesTests.cs (73)
152JsonElement expected = JsonDocument.Parse("""
174JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(MyPoco), serializerOptions: JsonContext.Default.Options);
182JsonElement expected = JsonDocument.Parse("""
189JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(object[]), serializerOptions: JsonContext.Default.Options);
197JsonElement expected = JsonDocument.Parse("""
232JsonElement actual = AIJsonUtilities.CreateJsonSchema(
246JsonElement expected = JsonDocument.Parse("""
282JsonElement actual = AIJsonUtilities.CreateJsonSchema(typeof(MyPoco), serializerOptions: JsonContext.Default.Options, inferenceOptions: inferenceOptions);
295JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(func.UnderlyingMethod, title: string.Empty);
322JsonElement expected = JsonDocument.Parse($$"""
358JsonElement resolvedSchema = AIJsonUtilities.CreateFunctionJsonSchema(func.UnderlyingMethod, title: string.Empty, description: string.Empty, inferenceOptions: inferenceOptions);
368JsonElement schemaParameters = func.JsonSchema.GetProperty("properties");
388JsonElement expected = JsonDocument.Parse($$"""
394JsonElement actualSchema = property.Value;
434JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method, title: string.Empty);
436Assert.True(schema.TryGetProperty("required", out JsonElement requiredElement));
496JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method, title: string.Empty, serializerOptions: options);
499Assert.True(schema.TryGetProperty("properties", out JsonElement properties));
500Assert.True(properties.TryGetProperty("input", out JsonElement inputSchema));
503Assert.True(inputSchema.TryGetProperty("required", out JsonElement requiredElement));
515JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(TypeWithRequiredMembers), serializerOptions: JsonContext.Default.Options);
517Assert.True(schema.TryGetProperty("required", out JsonElement requiredElement));
557JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method);
560Assert.True(doc.RootElement.TryGetProperty("title", out JsonElement titleElement));
562Assert.True(doc.RootElement.TryGetProperty("description", out JsonElement descElement));
576JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method, title: "override_title");
579Assert.True(doc.RootElement.TryGetProperty("title", out JsonElement titleElement));
586JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(object));
605JsonElement schema = AIJsonUtilities.CreateJsonSchema(testData.Type, serializerOptions: options, inferenceOptions: createOptions);
630JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(AIContent), serializerOptions: options);
640JsonElement expectedSchema = JsonDocument.Parse("""
647JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(MyEnumValue?), serializerOptions: JsonContext.Default.Options);
1135JsonElement expectedSchema = JsonDocument.Parse("""
1148JsonElement actualSchema = AIJsonUtilities.CreateJsonSchema(typeof(ClassWithNullableMaxLengthProperty), serializerOptions: JsonContext.Default.Options);
1270JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1298JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1303JsonElement properties = schema.GetProperty("properties");
1315JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1325JsonElement properties = schema.GetProperty("properties");
1339JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1344JsonElement properties = schema.GetProperty("properties");
1358JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1363JsonElement properties = schema.GetProperty("properties");
1376JsonElement schema = AIJsonUtilities.CreateFunctionJsonSchema(method.Method, inferenceOptions: new()
1385JsonElement properties = schema.GetProperty("properties");
1394JsonElement schema = JsonDocument.Parse("""
1405JsonElement expectedSchema = JsonDocument.Parse("""
1421JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1428JsonElement schema = JsonDocument.Parse("""
1439JsonElement expectedSchema = JsonDocument.Parse("""
1455JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1462JsonElement schema = JsonDocument.Parse("""
1473JsonElement expectedSchema = JsonDocument.Parse("""
1490JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1497JsonElement schema = JsonDocument.Parse("""
1509JsonElement expectedSchema = JsonDocument.Parse("""
1527JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1534JsonElement schema = JsonDocument.Parse("""
1542JsonElement expectedSchema = JsonDocument.Parse("""
1554JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, options);
1573JsonElement schema = AIJsonUtilities.CreateJsonSchema(testData.Type, serializerOptions: options, inferenceOptions: createOptions);
1591JsonElement transformedSchema = AIJsonUtilities.TransformSchema(schema, transformOptions);
1625JsonElement schema = JsonDocument.Parse("{}").RootElement;
1638JsonElement schema = JsonDocument.Parse(invalidSchema).RootElement;
1650JsonElement schema = JsonDocument.Parse(booleanSchema).RootElement;
1654JsonElement result = AIJsonUtilities.TransformSchema(schema, transformOptions);
1666Assert.True(result.TryGetProperty("not", out JsonElement notValue));
1676[JsonSerializable(typeof(JsonElement))]
1686private static bool DeepEquals(JsonElement element1, JsonElement element2)
1688return JsonElement.DeepEquals(element1, element2);
1691private static void AssertDeepEquals(JsonElement element1, JsonElement element2)
Microsoft.Extensions.AI.Evaluation.Safety (4)
Microsoft.Extensions.AI.Integration.Tests (7)
Microsoft.Extensions.AI.OpenAI (5)
Microsoft.Extensions.AI.OpenAI.Tests (30)
OpenAIConversionTests.cs (16)
113var jsonSchema = JsonDocument.Parse("""
144var root = parsedParams.RootElement;
146Assert.True(root.TryGetProperty("$defs", out var defs), "The $defs property should be preserved in the function parameters");
147Assert.True(defs.TryGetProperty("Person", out var person), "The Person definition should exist in $defs");
148Assert.True(person.TryGetProperty("properties", out var properties), "Person should have properties");
623var root = jsonDoc.RootElement;
626Assert.True(root.TryGetProperty("properties", out var properties));
627Assert.True(properties.TryGetProperty("name", out var nameProperty));
687Assert.True(JsonElement.DeepEquals(JsonSerializer.SerializeToElement(new Dictionary<string, object?>
691}), JsonElement.Parse(tc.FunctionArguments.ToMemory().Span)));
743Assert.True(JsonElement.DeepEquals(JsonSerializer.SerializeToElement(new Dictionary<string, object?>
747}), JsonElement.Parse(m3.FunctionArguments.ToMemory().Span)));
1080Assert.Equal(42, ((JsonElement)deserializedArgs["number"]!).GetInt32());
1081Assert.True(((JsonElement)deserializedArgs["boolean"]!).GetBoolean());
1084var nestedObj = (JsonElement)deserializedArgs["nestedObject"]!;
Microsoft.Extensions.AI.Tests (44)
Functions\AIFunctionFactoryTest.cs (31)
159AIFunction func = AIFunctionFactory.Create((JsonElement param) => param, serializerOptions: options);
160JsonElement expectedResult = JsonDocument.Parse(jsonStringParam, new() { CommentHandling = JsonCommentHandling.Skip }).RootElement;
179AIFunction func = AIFunctionFactory.Create((JsonElement param) => param);
180JsonElement expectedResult = JsonDocument.Parse(JsonSerializer.Serialize(invalidJsonParam, JsonContext.Default.String)).RootElement;
376var result = (JsonElement?)await func.InvokeAsync(new()
1004JsonElement expectedSchema = JsonDocument.Parse("""
1037JsonElement expectedSchema = JsonDocument.Parse("""
1074JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(int), serializerOptions: AIJsonUtilities.DefaultOptions);
1326JsonElement schema = func.JsonSchema;
1327JsonElement properties = schema.GetProperty("properties");
1330JsonElement nullableIntSchema = properties.GetProperty("nullableInt");
1332nullableIntSchema.TryGetProperty("type", out JsonElement nullableIntType),
1339JsonElement nullableIntWithDefaultSchema = properties.GetProperty("nullableIntWithDefault");
1341nullableIntWithDefaultSchema.TryGetProperty("type", out JsonElement nullableIntWithDefaultType),
1347nullableIntWithDefaultSchema.TryGetProperty("default", out JsonElement nullableIntWithDefaultDefault),
1352JsonElement required = schema.GetProperty("required");
1366JsonElement schema = func.JsonSchema;
1367JsonElement properties = schema.GetProperty("properties");
1370JsonElement nullableStringSchema = properties.GetProperty("nullableString");
1372nullableStringSchema.TryGetProperty("type", out JsonElement nullableStringType),
1379JsonElement nullableIntSchema = properties.GetProperty("nullableInt");
1381nullableIntSchema.TryGetProperty("type", out JsonElement nullableIntType),
1388JsonElement nullableStringWithDefaultSchema = properties.GetProperty("nullableStringWithDefault");
1390nullableStringWithDefaultSchema.TryGetProperty("type", out JsonElement nullableStringWithDefaultType),
1396nullableStringWithDefaultSchema.TryGetProperty("default", out JsonElement nullableStringWithDefaultDefault),
1401JsonElement nullableIntWithDefaultSchema = properties.GetProperty("nullableIntWithDefault");
1403nullableIntWithDefaultSchema.TryGetProperty("type", out JsonElement nullableIntWithDefaultType),
1409nullableIntWithDefaultSchema.TryGetProperty("default", out JsonElement nullableIntWithDefaultDefault),
1414JsonElement required = schema.GetProperty("required");
1446JsonElement schema = func.JsonSchema;
1447JsonElement properties = schema.GetProperty("properties");
Microsoft.Extensions.Configuration.Json (4)
Microsoft.ML.GenAI.Phi (4)
Microsoft.ML.Tokenizers.Tests (29)
BpeTests.cs (25)
956JsonElement root = doc.RootElement;
957if (!root.TryGetProperty("model", out JsonElement modelElement) ||
959!modelElement.TryGetProperty("type", out JsonElement typeElement) ||
961!modelElement.TryGetProperty("vocab", out JsonElement vocabElement) ||
969if (modelElement.TryGetProperty("unk_token", out JsonElement unKnownElement))
974if (modelElement.TryGetProperty("continuing_subword_prefix", out JsonElement continuingSubwordPrefixElement))
979if (modelElement.TryGetProperty("end_of_word_suffix", out JsonElement endOfWordSuffixElement))
984if (modelElement.TryGetProperty("fuse_unknown_tokens", out JsonElement fuseUnknownTokensElement))
1004private static IEnumerable<KeyValuePair<string, int>> GetVocabulary(JsonElement vocabElement)
1012private static IEnumerable<string> GetMerges(JsonElement modelElement)
1014if (modelElement.TryGetProperty("merges", out JsonElement mergesElement) && mergesElement.ValueKind == JsonValueKind.Array)
1016foreach (JsonElement merge in mergesElement.EnumerateArray())
1028private static IReadOnlyList<PreTokenizer>? GetPreTokenizer(JsonElement root, out bool byteLevel)
1033if (root.TryGetProperty("pre_tokenizer", out JsonElement preTokenizerElement) &&
1035preTokenizerElement.TryGetProperty("type", out JsonElement typeElement) &&
1038preTokenizerElement.TryGetProperty("pretokenizers", out JsonElement preTokenizersElement) &&
1041foreach (JsonElement preTokenizer in preTokenizersElement.EnumerateArray())
1044preTokenizer.TryGetProperty("type", out JsonElement preTokenizerTypeElement) &&
1050if (preTokenizer.TryGetProperty("pattern", out JsonElement patternElement) &&
1052patternElement.TryGetProperty("Regex", out JsonElement regexElement) &&
1073private static Dictionary<string, int>? GetSpecialTokens(JsonElement root)
1075if (root.TryGetProperty("added_tokens", out JsonElement modelElement) && modelElement.ValueKind == JsonValueKind.Array)
1078foreach (JsonElement token in modelElement.EnumerateArray())
1080if (token.TryGetProperty("content", out JsonElement contentElement) &&
1082token.TryGetProperty("id", out JsonElement idElement) && idElement.ValueKind == JsonValueKind.Number)
Microsoft.NET.Build.Containers (13)
LocalDaemons\DockerCli.cs (13)
249if (!config.RootElement.TryGetProperty("ServerErrors", out JsonElement errorProperty))
332var rootElement = GetDockerConfig().RootElement;
335if (rootElement.TryGetProperty("RegistryConfig", out var registryConfig) && registryConfig.ValueKind == JsonValueKind.Object)
337if (registryConfig.TryGetProperty("IndexConfigs", out var indexConfigs) && indexConfigs.ValueKind == JsonValueKind.Object)
342&& property.Value.TryGetProperty("Secure", out var secure)
353if (rootElement.TryGetProperty("registries", out var registries) && registries.ValueKind == JsonValueKind.Object)
358&& property.Value.TryGetProperty("Insecure", out var insecure)
706var dockerinfo = GetDockerConfig().RootElement;
710dockerinfo.TryGetProperty("DockerRootDir", out var dockerRootDir) && dockerRootDir.GetString() is not null;
711var hasPodmanProperty = dockerinfo.TryGetProperty("host", out var host) && host.TryGetProperty("buildahVersion", out var buildahVersion) && buildahVersion.GetString() is not null;
725if (!GetDockerConfig().RootElement.TryGetProperty("DriverStatus", out var driverStatus) || driverStatus.ValueKind != JsonValueKind.Array)
730foreach (var item in driverStatus.EnumerateArray())
Microsoft.NET.HostModel (2)
Microsoft.SourceLink.Tools.Package (1)
Microsoft.TemplateEngine.Edge (1)
Microsoft.TemplateEngine.Utils (1)
Microsoft.TemplateSearch.Common (1)
Microsoft.TestPlatform.CommunicationUtilities (103)
Microsoft.TestPlatform.TestHostRuntimeProvider (3)
NuGet.Protocol (6)
rzc (6)
Shared.Tests (4)
System.Text.Json (212)
System\Text\Json\Document\JsonElement.cs (27)
63public JsonElement this[int index]
108/// Gets a <see cref="JsonElement"/> representing the value of a required property identified
119/// A <see cref="JsonElement"/> representing the value of the requested property.
134public JsonElement GetProperty(string propertyName)
138if (TryGetProperty(propertyName, out JsonElement property))
147/// Gets a <see cref="JsonElement"/> representing the value of a required property identified
162/// A <see cref="JsonElement"/> representing the value of the requested property.
174public JsonElement GetProperty(ReadOnlySpan<char> propertyName)
176if (TryGetProperty(propertyName, out JsonElement property))
185/// Gets a <see cref="JsonElement"/> representing the value of a required property identified
202/// A <see cref="JsonElement"/> representing the value of the requested property.
214public JsonElement GetProperty(ReadOnlySpan<byte> utf8PropertyName)
216if (TryGetProperty(utf8PropertyName, out JsonElement property))
254public bool TryGetProperty(string propertyName, out JsonElement value)
288public bool TryGetProperty(ReadOnlySpan<char> propertyName, out JsonElement value)
324public bool TryGetProperty(ReadOnlySpan<byte> utf8PropertyName, out JsonElement value)
1238/// Compares the values of two <see cref="JsonElement"/> values for equality, including the values of all descendant elements.
1240/// <param name="element1">The first <see cref="JsonElement"/> to compare.</param>
1241/// <param name="element2">The second <see cref="JsonElement"/> to compare.</param>
1258public static bool DeepEquals(JsonElement element1, JsonElement element2)
1304foreach (JsonElement e1 in element1.EnumerateArray())
1368Dictionary<string, ValueQueue<JsonElement>> properties2 = new(capacity: remainingProps, StringComparer.Ordinal);
1373ref ValueQueue<JsonElement> values = ref CollectionsMarshal.GetValueRefOrAddDefault(properties2, prop2.Name, out bool _);
1388ref ValueQueue<JsonElement> values = ref CollectionsMarshal.GetValueRefOrAddDefault(properties2, prop.Name, out bool exists);
1392if (!exists || !values.TryDequeue(out JsonElement value) || !DeepEquals(prop.Value, value))
1693public 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)
77/// Converts the provided value into a <see cref="JsonElement"/>.
79/// <returns>A <see cref="JsonElement"/> representation of the value.</returns>
88public static JsonElement SerializeToElement(object? value, JsonTypeInfo jsonTypeInfo)
97/// Converts the provided value into a <see cref="JsonElement"/>.
99/// <returns>A <see cref="JsonElement"/> representation of the value.</returns>
114public static JsonElement SerializeToElement(object? value, Type inputType, JsonSerializerContext context)
123private static JsonElement WriteElement<TValue>(in TValue value, JsonTypeInfo<TValue> jsonTypeInfo)
133return JsonElement.Parse(output.WrittenSpan, options.GetDocumentOptions());
141private static JsonElement WriteElementAsObject(object? value, JsonTypeInfo jsonTypeInfo)
151return JsonElement.Parse(output.WrittenSpan, options.GetDocumentOptions());