Class JsonValue
- Namespace
- Nerdbank.Json
- Assembly
- Nerdbank.Json.dll
A compact, immutable, native representation of an arbitrary JSON value, usable without a static model.
public abstract class JsonValue : IEquatable<JsonValue>
- Inheritance
-
JsonValue
- Implements
- Derived
- Inherited Members
Remarks
This type is entirely self-contained: it does not depend on System.Text.Json, dynamic binding, or reflection,
so using it keeps the default serializer trimming-safe and NativeAOT-safe.
Numbers preserve their exact JSON token text (see JsonNumber), so a value round-trips without loss of precision or normalization.
Properties
Kind
Gets the kind of this value.
public abstract JsonValueKind Kind { get; }
Property Value
Null
Gets the JSON null literal.
public static JsonValue Null { get; }
Property Value
Methods
Create(bool)
Creates a JSON boolean value.
public static JsonValue Create(bool value)
Parameters
valueboolThe boolean.
Returns
- JsonValue
The value.
Create(decimal)
Creates a JSON number value.
public static JsonValue Create(decimal value)
Parameters
valuedecimalThe number.
Returns
- JsonValue
The value.
Create(double)
Creates a JSON number value.
public static JsonValue Create(double value)
Parameters
valuedoubleThe number.
Returns
- JsonValue
The value.
Create(long)
Creates a JSON number value.
public static JsonValue Create(long value)
Parameters
valuelongThe number.
Returns
- JsonValue
The value.
Create(string?)
public static JsonValue Create(string? value)
Parameters
valuestringThe string.
Returns
- JsonValue
The value.
Equals(JsonValue?)
Indicates whether the current object is equal to another object of the same type.
public abstract bool Equals(JsonValue? other)
Parameters
otherJsonValueAn object to compare with this object.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
public override abstract int GetHashCode()
Returns
- int
A hash code for the current object.