JsonString
Namespace: SnowBank.Data.Json · class
Implements: JsonValue, IEquatable<JsonValue>, IComparable<JsonValue>, IJsonSerializable, IFormattable, ISliceSerializable, IConvertible, IParsable<JsonValue>, ISpanParsable<JsonValue>, ISpanFormattable, IUtf8SpanFormattable, INumberBase<JsonValue>, IUtf8SpanParsable<JsonValue>, IAdditionOperators<JsonValue, JsonValue, JsonValue>, IAdditiveIdentity<JsonValue, JsonValue>, IDecrementOperators<JsonValue>, IDivisionOperators<JsonValue, JsonValue, JsonValue>, IEqualityOperators<JsonValue, JsonValue, bool>, IIncrementOperators<JsonValue>, IMultiplicativeIdentity<JsonValue, JsonValue>, IMultiplyOperators<JsonValue, JsonValue, JsonValue>, ISubtractionOperators<JsonValue, JsonValue, JsonValue>, IUnaryNegationOperators<JsonValue, JsonValue>, IUnaryPlusOperators<JsonValue, JsonValue>, IComparisonOperators<JsonValue, JsonValue, bool>, IEquatable<JsonString>, IComparable<JsonString>, IEquatable<string>, IComparable<string>, IEquatable<ReadOnlySpan<char>>, IEquatable<ReadOnlyMemory<char>>, IComparable<ReadOnlySpan<char>>, IComparable<ReadOnlyMemory<char>>, IEquatable<Guid>, IEquatable<Uuid128>, IEquatable<Uuid96>, IEquatable<Uuid80>, IEquatable<Uuid64>, IEquatable<DateTime>, IEquatable<DateTimeOffset>, IEquatable<DateOnly>, IEquatable<TimeOnly>, IEquatable<Instant>, IEquatable<LocalDateTime>, IEquatable<LocalDate>, IEquatable<Uri>, IEquatable<IPAddress>, IEquatable<Version>
JSON string literal
Properties
IsDefault
bool IsDefault { get; }
Tests if this value corresponds to the logical default for this type (0, false, null or missing, ...)
Returns: true for values like 0, false, or null; or false for non-zero integers, true, strings, arrays and objects
The empty string, array and object are NOT considered to be the default value of their type!
JsonNumber.Zero.IsDefault == true, JsonNumber.Return(123).IsDefault == false, JsonString.Return("").IsDefault == false, new JsonArray().IsDefault == false, new JsonObject().IsDefault == false
IsNull
bool IsNull { get; }
Tests if this value is null or missing
IsNullOrEmpty
bool IsNullOrEmpty { get; }
Returns true if the string is empty
IsReadOnly
bool IsReadOnly { get; }
Returns true if this value is read-only, and cannot be modified, or false if it allows mutations.
Only JSON Objects and Arrays can return false. All other "value types" (string, boolean, numbers, ...) are always immutable, and will always be read-only.
If you need to modify a JSON Object or Array that is read-only, you should first create a copy, by calling either Copy or ToMutable, perform any changes required, and then either Freeze the copy, or call ToReadOnly again.
Length
int Length { get; }
Gets the length of the string
Type
JsonType Type { get; }
Type of JSON value (Boolean, String, Number, Object, Array, ...)
Value
string Value { get; }
Gets the string literal
Methods
Bind
T Bind<T>(T defaultValue = null, ICrystalJsonTypeResolver resolver = null)
Bind this value into an instance of type TValue
defaultValue— Default value to return if the current instance is null or missingresolver— Optional custom resolver used to bind the value into a managed type.
Returns: An instance of the type TValue that is equivalent to the original JSON value, if there exists a valid conversion path. Otherwise, an exception will be thrown.
JsonNumber.Return(123).Bind
object Bind(Type type, ICrystalJsonTypeResolver resolver = null)
Bind this value into an instance of the specified type
type— Target managed typeresolver— Optional custom resolver used to bind the value into a managed type.
Returns: An instance of the target type that is equivalent to the original JSON value, if there exists a valid conversion path or convention. Otherwise, an exception will be thrown.
If the target type is a Value Type, the instance will be boxed, which may cause extra memory allocations. Consider calling instance, or use any of the convenience methods like , , ...
JsonNumber.Return(123).Bind(typeof(long)) will return a boxed Int64 with value 123.
CompareTo
int CompareTo(JsonValue other)
Compares two JSON values, and returns an integer that indicates whether the first value precedes, follows, or occurs in the same position in the sort order as the second value.
int CompareTo(JsonString other)
int CompareTo(string other)
int CompareTo(ReadOnlySpan<char> other)
int CompareTo(ReadOnlyMemory<char> other)
Contains
bool Contains(string value)
Tests if the string contains the specified literal
bool Contains(ReadOnlySpan<char> value)
Tests if the string contains the specified literal
bool Contains(ReadOnlyMemory<char> value)
Tests if the string contains the specified literal
bool Contains(JsonString value)
Tests if the string contains the specified literal
bool Contains(JsonValue value)
Tests if the string contains the specified literal
Create
static JsonString Create(string value)
Returns the equivalent JsonString
value— String literal
Returns: Equivalent JsonString, or the Empty singleton if value is empty
If could be null, call instead, which returns instead of an exception
static JsonString Create(char value)
Returns the equivalent JsonString
value— Character literal
Returns: Equivalent JsonString
static JsonString Create(ReadOnlySpan<char> value)
Returns the equivalent JsonString
value— String literal
Returns: Equivalent JsonString, or the Empty singleton if value is empty
static JsonString Create(ReadOnlyMemory<char> value)
Returns the equivalent JsonString
value— String literal
Returns: Equivalent JsonString, or the Empty singleton if value is empty
static JsonString Create(Slice value)
Returns the equivalent JsonString
value— Byte slice literal
Returns: Equivalent JsonString with value encoded as Base64, or the Empty singleton if value is empty
static JsonString Create(ReadOnlySpan<byte> value)
Returns the equivalent JsonString
value— Byte slice literal
Returns: Equivalent JsonString with value encoded as Base64, or the Empty singleton if value is empty
static JsonString Create(Guid value)
Returns the equivalent JsonString
The Empty guid is equivalent to the Empty string, which is a different behavior compared to Return.
static JsonString Create(Uuid128 value)
Returns the equivalent JsonString
The Empty guid is equivalent to the Empty string, which is a different behavior compared to Return.
static JsonString Create(DateTime value)
Returns the equivalent JsonString
static JsonString Create(DateTimeOffset value)
Returns the equivalent JsonString
static JsonString Create(DateOnly value)
Returns the equivalent JsonString
static JsonString Create(TimeOnly value)
Returns the equivalent JsonString
static JsonString Create(Instant value)
Returns the equivalent JsonString
EndsWith
bool EndsWith(string value)
Tests if the string ends with the specified literal
bool EndsWith(ReadOnlySpan<char> value)
Tests if the string ends with the specified literal
bool EndsWith(ReadOnlyMemory<char> value)
Tests if the string ends with the specified literal
bool EndsWith(JsonString value)
Tests if the string ends with the specified literal
bool EndsWith(JsonValue value)
Tests if the string ends with the specified literal
Equals
bool Equals(object obj)
bool Equals(JsonValue other)
Tests if these two JSON values are considered equal, using the relaxed JSON comparison semantics
Two values are considered "equal" if they would produce the same result when serialized using a canonical representation.
Numbers are equal if they represent the "same" number (ie: 1 and 1.0 are equal)
Numbers and strings can be equal, if the later can be parsed into a number equal to the former (ie: 123 and "123" are equal)
Arrays are equal if they have the same length and all their elements are equals pairwise
Objects are equal if they have the same key/value pairs, irrespective of their order.
A Missing field is not considered equal to an explicit Null field, and vice versa
If you require strict equality (ie: "123" and 123 are different), consider calling StrictEquals instead.
bool Equals(JsonString other)
bool Equals(string other)
bool Equals(ReadOnlySpan<char> other)
bool Equals(ReadOnlyMemory<char> other)
bool Equals(Guid other)
bool Equals(Uuid128 other)
bool Equals(Uuid96 other)
bool Equals(Uuid80 other)
bool Equals(Uuid64 other)
bool Equals(DateTime other)
bool Equals(DateTimeOffset other)
bool Equals(DateOnly other)
bool Equals(TimeOnly other)
bool Equals(Instant other)
bool Equals(LocalDateTime other)
bool Equals(LocalDate other)
bool Equals(IPAddress other)
bool Equals(Uri other)
bool Equals(Version other)
GetHashCode
int GetHashCode()
Returns a hash code that can be used to quickly identify a JSON value.
The hash code is guaranteed to remain unchanged during the lifetime of the object.
Caution: there is NO guarantee that two equivalent Objects or Arrays will have the same hash code! This means that it is NOT safe to use a JSON object or array has the key of a Dictionary or other collection that uses hash codes to quickly compare two instances.
IndexOf
int IndexOf(string value)
Returns the index of the first occurrence of the specified literal
Returns -1 if the string does not contain this literal
int IndexOf(ReadOnlySpan<char> value)
Returns the index of the first occurrence of the specified literal
Returns -1 if the string does not contain this literal
int IndexOf(ReadOnlyMemory<char> value)
Returns the index of the first occurrence of the specified literal
Returns -1 if the string does not contain this literal
int IndexOf(JsonString value)
Returns the index of the first occurrence of the specified literal
Returns -1 if the string does not contain this literal
int IndexOf(JsonValue value)
Returns the index of the first occurrence of the specified literal
Returns -1 if the string does not contain this literal
JsonSerialize
void JsonSerialize(CrystalJsonWriter writer)
Serializes this instance as JSON
writer— Writer that will output the content of this instance
Return
static JsonValue Return(string value)
Returns a JsonValue that is equivalent to the specified string literal
value— String literal, ornull
Returns: Equivalent JsonString, the Empty singleton if value is empty, or the Null singleton if value is null
static JsonValue Return(ReadOnlySpan<char> value)
Returns a JsonValue that is equivalent to the span of characters
value— String literal
Returns: Equivalent JsonString, or the Empty singleton if value is empty
static JsonValue Return(ReadOnlyMemory<char> value)
Returns a JsonValue that is equivalent to the span of characters
value— String literal
Returns: Equivalent JsonString, or the Empty singleton if value is empty
static JsonValue Return(StringBuilder value)
Returns a JsonValue that is equivalent to the content of the specified StringBuilder
value— String literal
Returns: Equivalent JsonString, or the Empty singleton if value is empty
static JsonValue Return(char value)
Returns a JsonValue that is equivalent to the specified character
value— Character literal
Returns: Equivalent JsonString
Please note that if is equal to 0, this method will return the "\x00" string
static JsonValue Return(char? value)
Returns a JsonValue that is equivalent to the specified character
value— Character literal, ornull
Returns: Equivalent JsonString, or the Null singleton if value is null
Please note that if is equal to 0, this method will return the "\x00" string
static JsonValue Return(byte[] value)
Returns the equivalent JsonString
static JsonValue Return(Slice value)
Returns the equivalent JsonString
static JsonValue Return(ReadOnlySpan<byte> value)
Returns the equivalent JsonString
static JsonValue Return(ReadOnlyMemory<byte> value)
Returns the equivalent JsonString
static JsonValue Return(ArraySegment<byte> value)
Returns the equivalent JsonString
static JsonValue Return(Guid value)
Returns the equivalent JsonString
The Empty guid is equivalent to a Null entry
static JsonValue Return(Guid? value)
Returns the equivalent JsonString
The Empty guid is equivalent to a Null entry
static JsonValue Return(Uuid128 value)
Returns the equivalent JsonString
The Empty uuid is equivalent to a Null entry
static JsonValue Return(Uuid128? value)
Returns the equivalent JsonString
The Empty uuid is equivalent to a Null entry
static JsonValue Return(Uuid96 value)
Returns the equivalent JsonString
The Empty uuid is equivalent to a Null entry
static JsonValue Return(Uuid96? value)
Returns the equivalent JsonString
The Empty uuid is equivalent to a Null entry
static JsonValue Return(Uuid80 value)
Returns the equivalent JsonString
The Empty uuid is equivalent to a Null entry
static JsonValue Return(Uuid80? value)
Returns the equivalent JsonString
The Empty uuid is equivalent to a Null entry
static JsonValue Return(Uuid64 value)
Returns the equivalent JsonString
The Empty uuid is equivalent to a Null entry
static JsonValue Return(Uuid64? value)
Returns the equivalent JsonString
The Empty uuid is equivalent to a Null entry
static JsonValue Return(IPAddress value)
Returns the equivalent JsonString
static JsonValue Return(Uri value)
Returns the equivalent JsonString
static JsonValue Return(Version value)
Returns the equivalent JsonString
static JsonValue Return(Type type)
Returns the equivalent JsonString
static JsonValue Return(DateTime value)
Returns the equivalent JsonString
static JsonValue Return(DateTime? value)
Returns the equivalent JsonString
static JsonValue Return(DateTimeOffset value)
Returns the equivalent JsonString
static JsonValue Return(DateTimeOffset? value)
Returns the equivalent JsonString
static JsonValue Return(DateOnly value)
Returns the equivalent JsonString
static JsonValue Return(DateOnly? value)
Returns the equivalent JsonString
static JsonValue Return(TimeOnly value)
Returns the equivalent JsonString
static JsonValue Return(TimeOnly? value)
Returns the equivalent JsonString
static JsonValue Return(Instant value)
Returns the equivalent JsonString
static JsonValue Return(Instant? value)
Returns the equivalent JsonString
static JsonValue Return(ZonedDateTime value)
Returns the equivalent JsonString
static JsonValue Return(ZonedDateTime? value)
Returns the equivalent JsonString
static JsonValue Return(DateTimeZone value)
Returns the equivalent JsonString
static JsonValue Return(LocalDateTime value)
Returns the equivalent JsonString
static JsonValue Return(LocalDateTime? value)
Returns the equivalent JsonString
static JsonValue Return(LocalDate value)
Returns the equivalent JsonString
static JsonValue Return(LocalDate? value)
Returns the equivalent JsonString
static JsonValue Return(LocalTime value)
Returns the equivalent JsonString
static JsonValue Return(LocalTime? value)
Returns the equivalent JsonString
static JsonValue Return(OffsetDateTime value)
Returns the equivalent JsonString
static JsonValue Return(OffsetDateTime? value)
Returns the equivalent JsonString
static JsonValue Return(Offset value)
Returns the equivalent JsonString
static JsonValue Return(Offset? value)
Returns the equivalent JsonString
static JsonValue Return(char[] value, int offset, int count)
Returns a JsonValue that is equivalent to the span of characters
value— Buffer that contains the string literaloffset— Offset to the start of the string literal invaluecount— Size (in characters) of the string literal
Returns: Equivalent JsonString, or the Empty singleton if count is 0
StartsWith
bool StartsWith(string value)
Tests if the string starts with the specified literal
bool StartsWith(ReadOnlySpan<char> value)
Tests if the string starts with the specified literal
bool StartsWith(ReadOnlyMemory<char> value)
Tests if the string starts with the specified literal
bool StartsWith(JsonString value)
Tests if the string starts with the specified literal
bool StartsWith(JsonValue value)
Tests if the string starts with the specified literal
StrictEquals
bool StrictEquals(JsonValue other)
Tests if these two JSON values are considered equal, using the strict JSON comparison semantics
For two values to be considered "equal", they must be of the same type (string, number, array, ...) AND have the same result when serialized using a canonical representation.
Arrays are equals if they have the same length and all their elements are also strictly equal.
Objects are equal if they have the same keys, irrespective of their order, and each value is strictly equal.
A Missing field is not considered equal to an explicit Null field, and vice versa
bool StrictEquals(JsonString other)
ToBoolean
bool ToBoolean(bool defaultValue = false)
Returns the equivalent Boolean, if there exists a valid conversion
ToBooleanOrDefault
bool? ToBooleanOrDefault(bool? defaultValue = null)
Returns the equivalent Boolean, if there exists a valid conversion
ToBuffer
byte[] ToBuffer()
Decodes this string as a Base64 encoded buffer
ToByte
byte ToByte(byte defaultValue = 0)
Returns the equivalent Byte, if there exists a valid conversion
ToByteOrDefault
byte? ToByteOrDefault(byte? defaultValue = null)
Returns the equivalent Byte, if there exists a valid conversion
ToChar
char ToChar(char defaultValue = '�')
Returns the equivalent Char, if there exists a valid conversion
ToCharOrDefault
char? ToCharOrDefault(char? defaultValue = null)
Returns the equivalent Char, if there exists a valid conversion
ToDateOnly
DateOnly ToDateOnly(DateOnly defaultValue = null)
Returns the equivalent DateOnly, if there exists a valid conversion
ToDateOnlyOrDefault
DateOnly? ToDateOnlyOrDefault(DateOnly? defaultValue = null)
Returns the equivalent DateOnly, if there exists a valid conversion
ToDateTime
DateTime ToDateTime(DateTime defaultValue = null)
Returns the equivalent DateTime, if there exists a valid conversion
ToDateTimeOffset
DateTimeOffset ToDateTimeOffset(DateTimeOffset defaultValue = null)
Returns the equivalent DateTimeOffset, if there exists a valid conversion
ToDateTimeOffsetOrDefault
DateTimeOffset? ToDateTimeOffsetOrDefault(DateTimeOffset? defaultValue = null)
Returns the equivalent DateTimeOffset, if there exists a valid conversion
ToDateTimeOrDefault
DateTime? ToDateTimeOrDefault(DateTime? defaultValue = null)
Returns the equivalent DateTime, if there exists a valid conversion
ToDateTimeZone
DateTimeZone ToDateTimeZone(DateTimeZone defaultValue = null)
ToDecimal
decimal ToDecimal(decimal defaultValue = 0)
Returns the equivalent Decimal, if there exists a valid conversion
ToDecimalOrDefault
decimal? ToDecimalOrDefault(decimal? defaultValue = null)
Returns the equivalent Decimal, if there exists a valid conversion
ToDouble
double ToDouble(double defaultValue = 0)
Returns the equivalent Double, if there exists a valid conversion
ToDoubleOrDefault
double? ToDoubleOrDefault(double? defaultValue = null)
Returns the equivalent Double, if there exists a valid conversion
ToDuration
Duration ToDuration(Duration defaultValue = null)
Returns the equivalent Duration, if there exists a valid conversion
ToDurationOrDefault
Duration? ToDurationOrDefault(Duration? defaultValue = null)
Returns the equivalent Duration, if there exists a valid conversion
ToEnum
TEnum ToEnum<TEnum>(TEnum defaultValue = null)
Returns the equivalent Enum, if there exists a valid conversion
ToEnumOrDefault
TEnum? ToEnumOrDefault<TEnum>(TEnum? defaultValue = null)
Returns the equivalent Enum, if there exists a valid conversion
ToGuid
Guid ToGuid(Guid defaultValue = null)
Returns the equivalent Guid, if there exists a valid conversion
ToGuidOrDefault
Guid? ToGuidOrDefault(Guid? defaultValue = null)
Returns the equivalent Guid, if there exists a valid conversion
ToHalf
Half ToHalf(Half defaultValue = null)
Returns the equivalent Half, if there exists a valid conversion
ToHalfOrDefault
Half? ToHalfOrDefault(Half? defaultValue = null)
Returns the equivalent Half, if there exists a valid conversion
ToInstant
Instant ToInstant(Instant defaultValue = null)
Returns the equivalent Instant, if there exists a valid conversion
ToInstantOrDefault
Instant? ToInstantOrDefault(Instant? defaultValue = null)
Returns the equivalent Instant, if there exists a valid conversion
ToInt128
Int128 ToInt128(Int128 defaultValue = null)
Returns the equivalent Int128, if there exists a valid conversion
ToInt128OrDefault
Int128? ToInt128OrDefault(Int128? defaultValue = null)
Returns the equivalent Int128, if there exists a valid conversion
ToInt16
short ToInt16(short defaultValue = 0)
Returns the equivalent Int16, if there exists a valid conversion
ToInt16OrDefault
short? ToInt16OrDefault(short? defaultValue = null)
Returns the equivalent Int16, if there exists a valid conversion
ToInt32
int ToInt32(int defaultValue = 0)
Returns the equivalent Int32, if there exists a valid conversion
ToInt32OrDefault
int? ToInt32OrDefault(int? defaultValue = null)
Returns the equivalent Int32, if there exists a valid conversion
ToInt64
long ToInt64(long defaultValue = 0)
Returns the equivalent Int64, if there exists a valid conversion
ToInt64OrDefault
long? ToInt64OrDefault(long? defaultValue = null)
Returns the equivalent Int64, if there exists a valid conversion
ToIpAddress
IPAddress ToIpAddress()
ToJsonText
string ToJsonText(CrystalJsonSettings settings = null, ICrystalJsonTypeResolver resolver = null)
Serializes this JSON value into a JSON string literal
settings— Settings used to change the serialized JSON output (optional)resolver— Optional custom resolver.
Returns: JSON text literal that can be written to disk, returned as the body of an HTTP request, or
var jsonText = new JsonObject() { ["hello"] = "world" }.ToJsonText(); // == "{ "hello": "world" }"
ToLocalDate
LocalDate ToLocalDate(LocalDate defaultValue = null)
ToLocalDateOrDefault
LocalDate? ToLocalDateOrDefault(LocalDate? defaultValue = null)
ToLocalDateTime
LocalDateTime ToLocalDateTime(LocalDateTime defaultValue = null)
ToLocalDateTimeOrDefault
LocalDateTime? ToLocalDateTimeOrDefault(LocalDateTime? defaultValue = null)
ToObject
object ToObject()
Converts this into a CLR object (with a type that matches the value)
Prefer casting to a specific type, using As
ToOffset
Offset ToOffset(Offset defaultValue = null)
ToOffsetDateTime
OffsetDateTime ToOffsetDateTime(OffsetDateTime defaultValue = null)
ToOffsetDateTimeOrDefault
OffsetDateTime? ToOffsetDateTimeOrDefault(OffsetDateTime? defaultValue = null)
ToOffsetOrDefault
Offset? ToOffsetOrDefault(Offset? defaultValue = null)
ToSByte
sbyte ToSByte(sbyte defaultValue = 0)
Returns the equivalent SByte, if there exists a valid conversion
ToSByteOrDefault
sbyte? ToSByteOrDefault(sbyte? defaultValue = null)
Returns the equivalent SByte, if there exists a valid conversion
ToSingle
float ToSingle(float defaultValue = 0)
Returns the equivalent Single, if there exists a valid conversion
ToSingleOrDefault
float? ToSingleOrDefault(float? defaultValue = null)
Returns the equivalent Single, if there exists a valid conversion
ToString
string ToString()
Converts this JSON value into a printable string
Please note that, due to convention in .NET, this will return the empty string for null values, since ToString must not return a null reference! Please call ToStringOrDefault if you need null references for null or missing JSON values.
See ToString if you need to specify a different format than the default
string ToString(string format, IFormatProvider provider = null)
Converts this JSON value into a printable string, using the specified format and provider
format— Desired format, or "D" (default) if omittedprovider— This parameter is ignored. JSON values are always formatted usingInvariantCulture.
Supported values for are:
- D Default, returns the value in the default format (no quotes for strings, ...)
- N Normal, equivalent to calling ToJsonText with Json
- C Compact, equivalent to calling ToJsonText with JsonCompact
- P Pretty, equivalent to calling ToJsonText with JsonIndented
- Q Quick, equivalent to calling
GetCompactRepresentation, that will return a simplified/partial version, suitable for logs/traces. - J JavaScript, equivalent to calling ToJsonText with JavaScript.
- B returns a doubly-encoded JSON version of this value, that can be passed through inside another JSON payload, or copy-pasted as a valid C# string literal.
ToStringOrDefault
string ToStringOrDefault(string defaultValue = null)
Returns the equivalent String, if there exists a valid conversion
ToTimeOnly
TimeOnly ToTimeOnly(TimeOnly defaultValue = null)
Returns the equivalent TimeOnly, if there exists a valid conversion
ToTimeOnlyOrDefault
TimeOnly? ToTimeOnlyOrDefault(TimeOnly? defaultValue = null)
Returns the equivalent TimeOnly, if there exists a valid conversion
ToTimeSpan
TimeSpan ToTimeSpan(TimeSpan defaultValue = null)
Returns the equivalent TimeSpan, if there exists a valid conversion
ToTimeSpanOrDefault
TimeSpan? ToTimeSpanOrDefault(TimeSpan? defaultValue = null)
Returns the equivalent TimeSpan, if there exists a valid conversion
ToUInt128
UInt128 ToUInt128(UInt128 defaultValue = null)
Returns the equivalent UInt128, if there exists a valid conversion
ToUInt128OrDefault
UInt128? ToUInt128OrDefault(UInt128? defaultValue = null)
Returns the equivalent UInt128, if there exists a valid conversion
ToUInt16
ushort ToUInt16(ushort defaultValue = 0)
Returns the equivalent UInt16, if there exists a valid conversion
ToUInt16OrDefault
ushort? ToUInt16OrDefault(ushort? defaultValue = null)
Returns the equivalent UInt16, if there exists a valid conversion
ToUInt32
uint ToUInt32(uint defaultValue = 0)
Returns the equivalent UInt32, if there exists a valid conversion
ToUInt32OrDefault
uint? ToUInt32OrDefault(uint? defaultValue = null)
Returns the equivalent UInt32, if there exists a valid conversion
ToUInt64
ulong ToUInt64(ulong defaultValue = 0)
Returns the equivalent UInt64, if there exists a valid conversion
ToUInt64OrDefault
ulong? ToUInt64OrDefault(ulong? defaultValue = null)
Returns the equivalent UInt64, if there exists a valid conversion
ToUri
Uri ToUri()
ToUuid128
Uuid128 ToUuid128(Uuid128 defaultValue = null)
Returns the equivalent Uuid128, if there exists a valid conversion
ToUuid128OrDefault
Uuid128? ToUuid128OrDefault(Uuid128? defaultValue = null)
Returns the equivalent Uuid128, if there exists a valid conversion
ToUuid64
Uuid64 ToUuid64(Uuid64 defaultValue = null)
Returns the equivalent Uuid64, if there exists a valid conversion
ToUuid64OrDefault
Uuid64? ToUuid64OrDefault(Uuid64? defaultValue = null)
Returns the equivalent Uuid64, if there exists a valid conversion
ToUuid80
Uuid80 ToUuid80(Uuid80 defaultValue = null)
Returns the equivalent Uuid80, if there exists a valid conversion
ToUuid80OrDefault
Uuid80? ToUuid80OrDefault(Uuid80? defaultValue = null)
Returns the equivalent Uuid80, if there exists a valid conversion
ToUuid96
Uuid96 ToUuid96(Uuid96 defaultValue = null)
Returns the equivalent Uuid96, if there exists a valid conversion
ToUuid96OrDefault
Uuid96? ToUuid96OrDefault(Uuid96? defaultValue = null)
Returns the equivalent Uuid96, if there exists a valid conversion
ToVersion
Version ToVersion()
ToZonedDateTime
ZonedDateTime ToZonedDateTime(ZonedDateTime defaultValue = null)
ToZonedDateTimeOrDefault
ZonedDateTime? ToZonedDateTimeOrDefault(ZonedDateTime? defaultValue = null)
TryConvertToDateOnly
bool TryConvertToDateOnly(out DateOnly result)
TryConvertToDateTime
bool TryConvertToDateTime(out DateTime result)
TryConvertToDateTimeOffset
bool TryConvertToDateTimeOffset(out DateTimeOffset dto)
TryConvertToDecimal
bool TryConvertToDecimal(out decimal value)
TryConvertToDouble
bool TryConvertToDouble(out double value)
TryConvertToGuid
bool TryConvertToGuid(out Guid result)
TryConvertToHalf
bool TryConvertToHalf(out Half value)
TryConvertToInstant
bool TryConvertToInstant(out Instant result)
TryConvertToInt128
bool TryConvertToInt128(out Int128 value)
TryConvertToInt16
bool TryConvertToInt16(out short value)
TryConvertToInt32
bool TryConvertToInt32(out int value)
TryConvertToInt64
bool TryConvertToInt64(out long value)
TryConvertToIpAddress
bool TryConvertToIpAddress(out IPAddress result)
TryConvertToLocalDate
bool TryConvertToLocalDate(out LocalDate result)
TryConvertToLocalDateTime
bool TryConvertToLocalDateTime(out LocalDateTime result)
TryConvertToSingle
bool TryConvertToSingle(out float value)
TryConvertToString
bool TryConvertToString(out string value)
TryConvertToTimeOnly
bool TryConvertToTimeOnly(out TimeOnly result)
TryConvertToTimeSpan
bool TryConvertToTimeSpan(out TimeSpan result)
TryConvertToUInt128
bool TryConvertToUInt128(out UInt128 value)
TryConvertToUInt16
bool TryConvertToUInt16(out ushort value)
TryConvertToUInt32
bool TryConvertToUInt32(out uint value)
TryConvertToUInt64
bool TryConvertToUInt64(out ulong value)
TryConvertToUri
bool TryConvertToUri(out Uri result)
TryConvertToUuid128
bool TryConvertToUuid128(out Uuid128 result)
TryConvertToUuid64
bool TryConvertToUuid64(out Uuid64 result)
TryConvertToUuid80
bool TryConvertToUuid80(out Uuid80 result)
TryConvertToUuid96
bool TryConvertToUuid96(out Uuid96 result)
TryConvertToVersion
bool TryConvertToVersion(out Version result)
TryFormat
bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = null, IFormatProvider provider = null)
bool TryFormat(Span<byte> destination, out int bytesWritten, ReadOnlySpan<char> format = null, IFormatProvider provider = null)
ValueEquals
bool ValueEquals<TValue>(TValue value, IEqualityComparer<TValue> comparer = null)
Tests if the current instance is equal to the specified value, using the strict JSON comparison semantics
value— Value to test with the current instancecomparer— Custom equality comparer if specified; otherwise, uses the default comparer for this type
Returns: true if both arguments are considered equal; otherwise, false
This method tries to perform an optimized comparison, and should perform less memory allocations than calling
WriteTo
void WriteTo(ref SliceWriter writer)
Serializes the current instance to the specified output buffer
Fields
Empty
static readonly JsonValue Empty
Returns the empty string