Record
public record FlattenedJsonNode : System.ValueType, System.IEquatable<Moka.Blazor.Json.Models.FlattenedJsonNode>

Namespace: Moka.Blazor.Json.Models

A flattened representation of a single JSON node used for virtualized rendering. Each instance represents one visible row in the tree view.

Remarks

This is a readonly record struct to minimize allocations during tree traversal.

Inheritance

Inherits from: System.ValueType

Implements: System.IEquatable<Moka.Blazor.Json.Models.FlattenedJsonNode>

Constructors

NameDescription
FlattenedJsonNode() A flattened representation of a single JSON node used for virtualized rendering. Each instance represents one visible row in the tree view.

FlattenedJsonNode()

public FlattenedJsonNode()

A flattened representation of a single JSON node used for virtualized rendering. Each instance represents one visible row in the tree view.

Remarks

This is a readonly record struct to minimize allocations during tree traversal.

Properties

NameDescription
ArrayIndex The index of this element within its parent array, or -1 if not an array element.
ChildCount The number of child elements (for objects: property count, for arrays: element count). Zero for primitive values.
Depth The depth of this node in the tree (root = 0).
HasTrailingComma Whether a comma should be rendered after this node (i.e., it is not the last sibling).
Id Unique identifier for this node within the current document, used for @key directives.
IsActiveSearchMatch Whether this node is the currently active/focused search match.
IsClosingBracket Whether this node is a closing bracket/brace for a collapsed container.
IsExpanded Whether this node is currently expanded (only meaningful for objects and arrays).
IsRangeGroup Whether this row groups a run of a large container's children rather than being a JSON node. FlattenedJsonNode.ChildCount is how many it holds and FlattenedJsonNode.Path is not a JSON Pointer.
IsSearchMatch Whether this node matches the current search query.
Path The JSON Pointer path (RFC 6901) to this node.
PropertyName The property name if this node is an object member; null for array elements or root.
RangeStart The position of the first child in this group, when FlattenedJsonNode.IsRangeGroup is set.
RawValue The raw string representation of the value for primitive types, or null for containers.
ValueKind The kind of JSON value at this node.

ArrayIndex

public int ArrayIndex { get; init; }

The index of this element within its parent array, or -1 if not an array element.

ChildCount

public required int ChildCount { get; init; }

The number of child elements (for objects: property count, for arrays: element count). Zero for primitive values.

Depth

public required int Depth { get; init; }

The depth of this node in the tree (root = 0).

HasTrailingComma

public required bool HasTrailingComma { get; init; }

Whether a comma should be rendered after this node (i.e., it is not the last sibling).

Id

public required int Id { get; init; }

Unique identifier for this node within the current document, used for @key directives.

IsActiveSearchMatch

public bool IsActiveSearchMatch { get; init; }

Whether this node is the currently active/focused search match.

IsClosingBracket

public bool IsClosingBracket { get; init; }

Whether this node is a closing bracket/brace for a collapsed container.

IsExpanded

public required bool IsExpanded { get; init; }

Whether this node is currently expanded (only meaningful for objects and arrays).

IsRangeGroup

public bool IsRangeGroup { get; init; }

Whether this row groups a run of a large container's children rather than being a JSON node. FlattenedJsonNode.ChildCount is how many it holds and FlattenedJsonNode.Path is not a JSON Pointer.

IsSearchMatch

public bool IsSearchMatch { get; init; }

Whether this node matches the current search query.

Path

public required string Path { get; init; }

The JSON Pointer path (RFC 6901) to this node.

PropertyName

public string? PropertyName { get; init; }

The property name if this node is an object member; null for array elements or root.

RangeStart

public int RangeStart { get; init; }

The position of the first child in this group, when FlattenedJsonNode.IsRangeGroup is set.

RawValue

public string? RawValue { get; init; }

The raw string representation of the value for primitive types, or null for containers.

ValueKind

public required JsonValueKind ValueKind { get; init; }

The kind of JSON value at this node.

Type Relationships
classDiagram
    style FlattenedJsonNode fill:#f9f,stroke:#333,stroke-width:2px
    FlattenedJsonNode --|> ValueType : inherits
    FlattenedJsonNode ..|> FlattenedJsonNode~ : implements
View Source
/// <summary>
///     A flattened representation of a single JSON node used for virtualized rendering.
///     Each instance represents one visible row in the tree view.
/// </summary>
/// <remarks>
///     This is a readonly record struct to minimize allocations during tree traversal.
/// </remarks>
public readonly record struct FlattenedJsonNode()
{
    /// <summary>
    ///     Unique identifier for this node within the current document, used for <c>@key</c> directives.
    /// </summary>
    public required int Id { get; init; }
    /// <summary>
    ///     The JSON Pointer path (RFC 6901) to this node.
    /// </summary>
    public required string Path { get; init; }
    /// <summary>
    ///     The depth of this node in the tree (root = 0).
    /// </summary>
    public required int Depth { get; init; }
    /// <summary>
    ///     The property name if this node is an object member; <c>null</c> for array elements or root.
    /// </summary>
    public string? PropertyName { get; init; }
    /// <summary>
    ///     The kind of JSON value at this node.
    /// </summary>
    public required JsonValueKind ValueKind { get; init; }
    /// <summary>
    ///     The raw string representation of the value for primitive types, or <c>null</c> for containers.
    /// </summary>
    public string? RawValue { get; init; }
    /// <summary>
    ///     The number of child elements (for objects: property count, for arrays: element count).
    ///     Zero for primitive values.
    /// </summary>
    public required int ChildCount { get; init; }
    /// <summary>
    ///     The index of this element within its parent array, or <c>-1</c> if not an array element.
    /// </summary>
    public int ArrayIndex { get; init; } = -1;
    /// <summary>
    ///     Whether this node is currently expanded (only meaningful for objects and arrays).
    /// </summary>
    public required bool IsExpanded { get; init; }
    /// <summary>
    ///     Whether this node is a closing bracket/brace for a collapsed container.
    /// </summary>
    public bool IsClosingBracket { get; init; }
    /// <summary>
    ///     Whether this node matches the current search query.
    /// </summary>
    public bool IsSearchMatch { get; init; }
    /// <summary>
    ///     Whether this node is the currently active/focused search match.
    /// </summary>
    public bool IsActiveSearchMatch { get; init; }
    /// <summary>
    ///     Whether a comma should be rendered after this node (i.e., it is not the last sibling).
    /// </summary>
    public required bool HasTrailingComma { get; init; }
    /// <summary>
    ///     Whether this row groups a run of a large container's children rather than being a JSON node.
    ///     <see cref = "ChildCount"/> is how many it holds and <see cref = "Path"/> is not a JSON Pointer.
    /// </summary>
    public bool IsRangeGroup { get; init; }
    /// <summary>
    ///     The position of the first child in this group, when <see cref = "IsRangeGroup"/> is set.
    /// </summary>
    public int RangeStart { get; init; }
}
Was this page helpful?