Skip to content

API Reference


API Reference / @dasch-ng/json-viewer / Segment

Interface: Segment

Defined in: segment.ts:19

Represents a single key-value pair in the JSON viewer tree.

Remarks

Each segment contains metadata about a JSON value including its type, string representation, and expansion state. Segments are used internally by the component to render the tree structure.

Properties

description

description: string

Defined in: segment.ts:59

A string representation of the value for display.

Remarks

Formatted based on the value type:

  • Strings: wrapped in quotes
  • Arrays: shows length and JSON representation
  • Objects: shows JSON representation
  • Primitives: toString() representation
  • Circular references: marked as [Circular]

expanded

expanded: boolean

Defined in: segment.ts:68

Whether this segment is currently expanded in the tree.

Remarks

Only meaningful for expandable types (objects and arrays). Users can toggle this by clicking on the segment.


key

key: string

Defined in: segment.ts:28

The key name for this value.

Remarks

For object properties, this is the property name. For array items, this is the index. For primitive root values, this is a type descriptor like (string).


type

type: SegmentType | undefined

Defined in: segment.ts:46

The type of this value.

Remarks

Determines how the value is styled and displayed in the viewer. Can be undefined during initialization before type detection.


value

value: unknown

Defined in: segment.ts:37

The actual value being displayed.

Remarks

Can be any JavaScript value. Circular references will be replaced with { $ref: "path" } objects by the component's decycle function.

Released under the MIT License.