Table of Contents

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

JsonValueKind

Null

Gets the JSON null literal.

public static JsonValue Null { get; }

Property Value

JsonValue

Methods

Create(bool)

Creates a JSON boolean value.

public static JsonValue Create(bool value)

Parameters

value bool

The boolean.

Returns

JsonValue

The value.

Create(decimal)

Creates a JSON number value.

public static JsonValue Create(decimal value)

Parameters

value decimal

The number.

Returns

JsonValue

The value.

Create(double)

Creates a JSON number value.

public static JsonValue Create(double value)

Parameters

value double

The number.

Returns

JsonValue

The value.

Create(long)

Creates a JSON number value.

public static JsonValue Create(long value)

Parameters

value long

The number.

Returns

JsonValue

The value.

Create(string?)

Creates a JSON string value, or the null literal when value is null.

public static JsonValue Create(string? value)

Parameters

value string

The 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

other JsonValue

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override abstract int GetHashCode()

Returns

int

A hash code for the current object.