4 types derived from JsonValue
System.Text.Json (4)
778 references to JsonValue
AnalyzeCiFailure (17)
AnalyzeCiFailure.TestHost (1)
AnalyzeCiFailure.Tests (21)
aspire (47)
Aspire.Cli.Tests (74)
Commands\DescribeCommandTests.cs (14)
408[KnownProperties.Executable.Path] = JsonValue.Create("dotnet"),
409[KnownProperties.Project.Configuration] = JsonValue.Create("Release"),
410[KnownProperties.Project.LaunchCommand] = JsonValue.Create("watch"),
411[KnownProperties.Project.LaunchProfile] = JsonValue.Create("https"),
412[KnownProperties.Project.Path] = JsonValue.Create("/repo/api/Api.csproj"),
413[KnownProperties.Project.TargetFramework] = JsonValue.Create("net10.0"),
414[KnownProperties.Resource.LaunchConfigurationType] = JsonValue.Create("project"),
415[KnownProperties.Resource.ParentName] = JsonValue.Create("group"),
428[KnownProperties.Executable.Path] = JsonValue.Create("dotnet"),
429[KnownProperties.Executable.Pid] = JsonValue.Create(1234),
430[KnownProperties.Project.LaunchProfile] = JsonValue.Create("AndroidEmulator"),
431[KnownProperties.Project.Path] = JsonValue.Create("/repo/maui/MauiApp.csproj"),
432[KnownProperties.Resource.LaunchConfigurationType] = JsonValue.Create("maui"),
433[KnownProperties.Resource.ParentName] = JsonValue.Create("mauiapp"),
Aspire.Dashboard (12)
Aspire.Dashboard.Tests (2)
Aspire.Hosting (29)
Backchannel\AuxiliaryBackchannelRpcTarget.cs (18)
1416string stringValue => JsonValue.Create(stringValue),
1417bool boolValue => JsonValue.Create(boolValue),
1418byte byteValue => JsonValue.Create(byteValue),
1419sbyte sbyteValue => JsonValue.Create(sbyteValue),
1420short shortValue => JsonValue.Create(shortValue),
1421ushort ushortValue => JsonValue.Create(ushortValue),
1422int intValue => JsonValue.Create(intValue),
1423uint uintValue => JsonValue.Create(uintValue),
1424long longValue => JsonValue.Create(longValue),
1425ulong ulongValue => JsonValue.Create(ulongValue),
1426float floatValue => JsonValue.Create(floatValue),
1427double doubleValue => JsonValue.Create(doubleValue),
1428decimal decimalValue => JsonValue.Create(decimalValue),
1431_ => JsonValue.Create(value.ToString())
1450return stringValue is null ? null : JsonValue.Create(stringValue);
1458JsonValue jsonValue when jsonValue.TryGetValue<string>(out var stringValue) => stringValue,
1459JsonValue jsonValue when jsonValue.TryGetValue<bool>(out var boolValue) => boolValue.ToString(CultureInfo.InvariantCulture),
1460JsonValue jsonValue when jsonValue.TryGetValue<IFormattable>(out var formattableValue) => formattableValue.ToString(null, CultureInfo.InvariantCulture),
Aspire.Hosting.Azure (2)
Aspire.Hosting.Azure.Sandboxes (1)
Aspire.Hosting.Azure.Tests (2)
Aspire.Hosting.Azure.WebPubSub (1)
Aspire.Hosting.CodeGeneration.Go (3)
Aspire.Hosting.CodeGeneration.Go.Tests (7)
GoGeneratorEscapingTests.cs (4)
200Value = JsonValue.Create("primary"),
207ExportedValue(["Emoji", "Greeting"], stringType, JsonValue.Create("hi \U0001F600")),
209ExportedValue(["Emoji", "Status"], enumType, JsonValue.Create("Ready\U0001F600")),
210ExportedValue(["Emoji", "Anything"], unknownType, JsonValue.Create("\U0001F600"))
Aspire.Hosting.CodeGeneration.Java (1)
Aspire.Hosting.CodeGeneration.Python (4)
Aspire.Hosting.CodeGeneration.Rust (1)
Aspire.Hosting.CodeGeneration.TypeScript (3)
Aspire.Hosting.Native.Client (1)
Aspire.Hosting.Native.Core.Tests (69)
ApplicationRevisionTests.cs (20)
23Arguments(("context", context.Writer), ("stream", JsonValue.Create("stdout")), ("message", JsonValue.Create("retained")))));
25Arguments(("context", context.Writer), ("name", JsonValue.Create("ping")), ("displayName", JsonValue.Create("Ping")))));
39Arguments(("context", context.Reader), ("resourceId", resourceId), ("afterSequence", JsonValue.Create(0)))));
56("context", context.Writer), ("name", JsonValue.Create("ping")), ("displayName", JsonValue.Create("Ping")))));
58("context", context.Reader), ("resourceName", JsonValue.Create("cache")), ("commandName", JsonValue.Create("ping")))));
60("context", context.Writer), ("message", JsonValue.Create("Keep running?")))));
78("accepted", JsonValue.Create(true)))));
158Arguments(("context", revision), ("name", JsonValue.Create("cache")), ("typeId", JsonValue.Create("other/Resource")))));
174Arguments(("context", context.Writer), ("revision", JsonValue.Create(1L)), ("timeoutMilliseconds", JsonValue.Create(10000))));
328("context", context.Writer), ("revision", JsonValue.Create(1L)), ("timeoutMilliseconds", JsonValue.Create(10000))));
330("context", context.Writer), ("timeoutMilliseconds", JsonValue.Create(10000))));
367Arguments(("context", writer), ("revision", JsonValue.Create(revision)), ("container", new JsonObject
392("context", context.Writer), ("revision", JsonValue.Create(revision)),
NativeDashboardTests.cs (10)
53("name", JsonValue.Create("refresh")), ("displayName", JsonValue.Create("Refresh"))));
55("stream", JsonValue.Create("stderr")), ("message", JsonValue.Create("native log"))));
95("name", JsonValue.Create("refresh")), ("displayName", JsonValue.Create("Refresh"))));
97("timeoutMilliseconds", JsonValue.Create(10000))));
109("message", JsonValue.Create("Initialize database?")))));
129("message", JsonValue.Create("Continue after the previous response?")))));
172("context", context.Writer), ("revision", JsonValue.Create(2L)),
NativeRpcTests.cs (9)
61Arguments(("context", composition), ("name", JsonValue.Create("late")), ("typeId", JsonValue.Create("example/Resource"))))));
135("name", JsonValue.Create("password")), ("value", JsonValue.Create("rpc-secret")))));
138Arguments(("context", resource), ("name", JsonValue.Create("password")), ("value", value)))));
163("name", JsonValue.Create("private-secret-name")), ("typeId", JsonValue.Create("example/Resource"))));
209("name", JsonValue.Create("overflow")), ("typeId", JsonValue.Create("example/Resource"))));
RuntimeRpcTests.cs (23)
21("stream", JsonValue.Create("stdout")), ("message", JsonValue.Create($"entry-{index}"))));
25("resourceId", id), ("afterSequence", JsonValue.Create(0)))));
28("message", JsonValue.Create("Continue?"))))));
30("message", JsonValue.Create("Another confirmation?"))))));
39("context", context.Reader), ("version", initial["version"]), ("timeoutMilliseconds", JsonValue.Create(30000))));
81("stream", JsonValue.Create("stdout")), ("message", JsonValue.Create($"entry-{index}"))));
85("resourceId", id), ("afterSequence", JsonValue.Create(0)))));
91("resourceId", id), ("afterSequence", JsonValue.Create(298)))));
95("resourceId", id), ("afterSequence", JsonValue.Create(301))))));
103("name", JsonValue.Create("refresh")), ("displayName", JsonValue.Create("Refresh"))));
105("resourceName", JsonValue.Create("cache")), ("commandName", JsonValue.Create("refresh")))));
116("message", JsonValue.Create("Continue?")))));
122("requestId", prompt["requestId"]), ("accepted", JsonValue.Create(true))));
125("requestId", prompt["requestId"]), ("accepted", JsonValue.Create(true))))));
134("name", JsonValue.Create("refresh")), ("displayName", JsonValue.Create("Refresh"))));
136("resourceName", JsonValue.Create("cache")), ("commandName", JsonValue.Create("refresh")))));
152("message", JsonValue.Create("Continue?")))));
Aspire.Hosting.Native.Server (41)
Aspire.Hosting.Radius (1)
Aspire.Hosting.RemoteHost (34)
Ats\AtsMarshaller.cs (21)
159AtsTypeCategory.Enum => JsonValue.Create(value.ToString()),
217AtsTypeCategory.Enum => JsonValue.Create(value.ToString()),
234return JsonValue.Create(((TimeSpan)value).TotalMilliseconds);
240return JsonValue.Create(((DateOnly)value).ToString("O", System.Globalization.CultureInfo.InvariantCulture));
246return JsonValue.Create(((TimeOnly)value).ToString("O", System.Globalization.CultureInfo.InvariantCulture));
249return JsonValue.Create(value);
456AtsTypeCategory.Enum => JsonValue.Create(value.ToString()),
484return JsonValue.Create(tokenId);
562return node is JsonValue value ? ConvertPrimitive(value, targetType) : node;
569if (node is JsonValue callbackValue && callbackValue.TryGetValue<string>(out var callbackId))
585if (node is JsonValue tokenValue && tokenValue.TryGetValue<string>(out var tokenId) && !string.IsNullOrEmpty(tokenId))
598if (node is JsonValue value)
724JsonValue v when v.TryGetValue<string>(out _) => "string",
725JsonValue v when v.TryGetValue<bool>(out _) => "bool",
726JsonValue v when v.TryGetValue<long>(out _) => "number",
727JsonValue v when v.TryGetValue<double>(out _) => "number",
728JsonValue => "value",
753private static decimal ReadDecimalValue(JsonValue value, Type targetType)
791private static decimal ReadIntegralNumericValue(JsonValue value, Type targetType, decimal minValue, decimal maxValue)
839public static object? ConvertPrimitive(JsonValue value, Type targetType)
1036var value = jsonValue is JsonValue primitive && primitive.GetValueKind() == JsonValueKind.Number &&
Aspire.Hosting.RemoteHost.Tests (100)
AtsMarshallerTests.cs (72)
52public static TheoryData<Type, JsonValue, object> WholeDoubleAdditionalIntegralTypes => new()
54{ typeof(byte), JsonValue.Create(42.0)!, (byte)42 },
55{ typeof(short), JsonValue.Create(42.0)!, (short)42 },
56{ typeof(uint), JsonValue.Create(42.0)!, 42u },
57{ typeof(ulong), JsonValue.Create(42.0)!, 42ul },
58{ typeof(ushort), JsonValue.Create(42.0)!, (ushort)42 },
59{ typeof(sbyte), JsonValue.Create(42.0)!, (sbyte)42 },
62public static TheoryData<Type, JsonValue> FractionalAdditionalIntegralTypes => new()
64{ typeof(byte), JsonValue.Create(42.5)! },
65{ typeof(short), JsonValue.Create(42.5)! },
66{ typeof(uint), JsonValue.Create(42.5)! },
67{ typeof(ulong), JsonValue.Create(42.5)! },
68{ typeof(ushort), JsonValue.Create(42.5)! },
69{ typeof(sbyte), JsonValue.Create(42.5)! },
72public static TheoryData<Type, JsonValue> OverflowAdditionalIntegralTypes => new()
74{ typeof(byte), JsonValue.Create(256.0)! },
75{ typeof(short), JsonValue.Create(32768.0)! },
76{ typeof(uint), JsonValue.Create(-1.0)! },
77{ typeof(ulong), JsonValue.Create(-1.0)! },
78{ typeof(ushort), JsonValue.Create(65536.0)! },
79{ typeof(sbyte), JsonValue.Create(128.0)! },
278var tokenValue = Assert.IsAssignableFrom<JsonValue>(result);
299var tokenValue = Assert.IsAssignableFrom<JsonValue>(result);
309var value = JsonValue.Create("test");
319var value = JsonValue.Create(42);
329var value = JsonValue.Create(11433.0);
339var value = JsonValue.Create(11433.5);
346public void ConvertPrimitive_ConvertsWholeDoubleForAdditionalIntegralTypes(Type targetType, JsonValue value, object expected)
355public void ConvertPrimitive_RejectsFractionalDoubleForAdditionalIntegralTypes(Type targetType, JsonValue value)
362public void ConvertPrimitive_RejectsOutOfRangeValuesForAdditionalIntegralTypes(Type targetType, JsonValue value)
370var value = JsonValue.Create(true);
380var value = JsonValue.Create(1500.0);
390var value = JsonValue.Create(42);
535var value = JsonValue.Create("2024-06-15");
558var value = JsonValue.Create("14:30:45");
655var value = JsonValue.Create(9223372036854775807L);
665var value = JsonValue.Create(5000000000d);
675var value = JsonValue.Create(9007199254740992d);
683var value = JsonValue.Create(3.14159);
693var value = JsonValue.Create(1e100);
703var value = JsonValue.Create(3.14);
713var value = JsonValue.Create(123.456m);
723var value = JsonValue.Create(1e100);
731var value = JsonValue.Create("01:30:00");
918var json = JsonValue.Create("ValueB");
929var json = JsonValue.Create("valueb"); // lowercase
940var json = JsonValue.Create(1); // ValueB is index 1
951var json = JsonValue.Create("ValueA");
Aspire.Hosting.Tests (15)
ConfigurationSchemaGenerator (1)
dotnet-user-jwts (1)
Infrastructure.Tests (3)
Microsoft.AspNetCore.JsonPatch.SystemTextJson (2)
Microsoft.AspNetCore.OpenApi (5)
Microsoft.Extensions.AI (1)
Microsoft.Extensions.AI.Abstractions (1)
Microsoft.Extensions.AI.Abstractions.Tests (3)
Microsoft.ML.AutoML (9)
Microsoft.NET.Build.Containers (2)
Microsoft.NET.Build.Tasks (3)
Microsoft.TemplateEngine.Cli (6)
Microsoft.TemplateEngine.Edge (3)
Microsoft.TemplateEngine.Orchestrator.RunnableProjects (4)
Microsoft.TemplateEngine.Utils (3)
Microsoft.TemplateSearch.Common (5)
NativeIntegrations.DockerCompose (10)
Shared.Tests (3)
System.Text.Json (224)
System\Text\Json\Nodes\JsonValue.CreateOverloads.cs (142)
12/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
14/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
16/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
17public static JsonValue Create(bool value, JsonNodeOptions? options = null) => new JsonValuePrimitive<bool>(value, JsonMetadataServices.BooleanConverter, options);
20/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
22/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
24/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
25public static JsonValue? Create(bool? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<bool>(value.Value, JsonMetadataServices.BooleanConverter, options) : null;
28/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
30/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
32/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
33public static JsonValue Create(byte value, JsonNodeOptions? options = null) => new JsonValuePrimitive<byte>(value, JsonMetadataServices.ByteConverter, options);
36/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
38/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
40/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
41public static JsonValue? Create(byte? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<byte>(value.Value, JsonMetadataServices.ByteConverter, options) : null;
44/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
46/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
48/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
49public static JsonValue Create(char value, JsonNodeOptions? options = null) => new JsonValuePrimitive<char>(value, JsonMetadataServices.CharConverter, options);
52/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
54/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
56/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
57public static JsonValue? Create(char? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<char>(value.Value, JsonMetadataServices.CharConverter, options) : null;
60/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
62/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
64/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
65public static JsonValue Create(DateTime value, JsonNodeOptions? options = null) => new JsonValuePrimitive<DateTime>(value, JsonMetadataServices.DateTimeConverter, options);
68/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
70/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
72/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
73public static JsonValue? Create(DateTime? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<DateTime>(value.Value, JsonMetadataServices.DateTimeConverter, options) : null;
76/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
78/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
80/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
81public static JsonValue Create(DateTimeOffset value, JsonNodeOptions? options = null) => new JsonValuePrimitive<DateTimeOffset>(value, JsonMetadataServices.DateTimeOffsetConverter, options);
84/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
86/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
88/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
89public static JsonValue? Create(DateTimeOffset? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<DateTimeOffset>(value.Value, JsonMetadataServices.DateTimeOffsetConverter, options) : null;
92/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
94/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
96/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
97public static JsonValue Create(decimal value, JsonNodeOptions? options = null) => new JsonValuePrimitive<decimal>(value, JsonMetadataServices.DecimalConverter, options);
100/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
102/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
104/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
105public static JsonValue? Create(decimal? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<decimal>(value.Value, JsonMetadataServices.DecimalConverter, options) : null;
108/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
110/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
112/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
113public static JsonValue Create(double value, JsonNodeOptions? options = null) => new JsonValuePrimitive<double>(value, JsonMetadataServices.DoubleConverter, options);
116/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
118/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
120/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
121public static JsonValue? Create(double? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<double>(value.Value, JsonMetadataServices.DoubleConverter, options) : null;
124/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
126/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
128/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
129public static JsonValue Create(Guid value, JsonNodeOptions? options = null) => new JsonValuePrimitive<Guid>(value, JsonMetadataServices.GuidConverter, options);
132/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
134/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
136/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
137public static JsonValue? Create(Guid? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<Guid>(value.Value, JsonMetadataServices.GuidConverter, options) : null;
140/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
142/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
144/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
145public static JsonValue Create(short value, JsonNodeOptions? options = null) => new JsonValuePrimitive<short>(value, JsonMetadataServices.Int16Converter, options);
148/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
150/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
152/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
153public static JsonValue? Create(short? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<short>(value.Value, JsonMetadataServices.Int16Converter, options) : null;
156/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
158/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
160/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
161public static JsonValue Create(int value, JsonNodeOptions? options = null) => new JsonValuePrimitive<int>(value, JsonMetadataServices.Int32Converter, options);
164/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
166/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
168/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
169public static JsonValue? Create(int? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<int>(value.Value, JsonMetadataServices.Int32Converter, options) : null;
172/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
174/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
176/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
177public static JsonValue Create(long value, JsonNodeOptions? options = null) => new JsonValuePrimitive<long>(value, JsonMetadataServices.Int64Converter, options);
180/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
182/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
184/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
185public static JsonValue? Create(long? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<long>(value.Value, JsonMetadataServices.Int64Converter, options) : null;
188/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
190/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
192/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
194public static JsonValue Create(sbyte value, JsonNodeOptions? options = null) => new JsonValuePrimitive<sbyte>(value, JsonMetadataServices.SByteConverter, options);
197/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
199/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
201/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
203public static JsonValue? Create(sbyte? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<sbyte>(value.Value, JsonMetadataServices.SByteConverter, options) : null;
206/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
208/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
210/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
211public static JsonValue Create(float value, JsonNodeOptions? options = null) => new JsonValuePrimitive<float>(value, JsonMetadataServices.SingleConverter, options);
214/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
216/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
218/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
219public static JsonValue? Create(float? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<float>(value.Value, JsonMetadataServices.SingleConverter, options) : null;
222/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
224/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
226/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
228public static JsonValue? Create(string? value, JsonNodeOptions? options = null) => value is not null ? new JsonValuePrimitive<string>(value, JsonMetadataServices.StringConverter!, options) : null;
231/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
233/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
235/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
237public static JsonValue Create(ushort value, JsonNodeOptions? options = null) => new JsonValuePrimitive<ushort>(value, JsonMetadataServices.UInt16Converter, options);
240/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
242/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
244/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
246public static JsonValue? Create(ushort? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<ushort>(value.Value, JsonMetadataServices.UInt16Converter, options) : null;
249/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
251/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
253/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
255public static JsonValue Create(uint value, JsonNodeOptions? options = null) => new JsonValuePrimitive<uint>(value, JsonMetadataServices.UInt32Converter, options);
258/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
260/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
262/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
264public static JsonValue? Create(uint? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<uint>(value.Value, JsonMetadataServices.UInt32Converter, options) : null;
267/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
269/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
271/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
273public static JsonValue Create(ulong value, JsonNodeOptions? options = null) => new JsonValuePrimitive<ulong>(value, JsonMetadataServices.UInt64Converter, options);
276/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
278/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
280/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
282public static JsonValue? Create(ulong? value, JsonNodeOptions? options = null) => value.HasValue ? new JsonValuePrimitive<ulong>(value.Value, JsonMetadataServices.UInt64Converter, options) : null;
285/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
287/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
289/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
290public static JsonValue? Create(JsonElement value, JsonNodeOptions? options = null) => JsonValue.CreateFromElement(ref value, options);
293/// Initializes a new instance of the <see cref="JsonValue"/> class that contains the specified value.
295/// <param name="value">The underlying value of the new <see cref="JsonValue"/> instance.</param>
297/// <returns>The new instance of the <see cref="JsonValue"/> class that contains the specified value.</returns>
298public static JsonValue? Create(JsonElement? value, JsonNodeOptions? options = null) => value is JsonElement element ? JsonValue.CreateFromElement(ref element, options) : null;