reablocks
Version:
Component library for React
38 lines (37 loc) • 1.17 kB
TypeScript
export interface ParseJsonInputs {
/**
* The JSON data to parse into a tree structure.
*/
data: any;
/**
* Identifier for the current node, used as a key prefix for descendants.
* @default 'root'
*/
id?: string;
/**
* Display label for the current node.
*/
label?: string;
/**
* Index of the current node within its parent (used for array items).
*/
index?: number;
/**
* Whether to include nodes with empty values in the parsed tree.
* @default true
*/
showEmpty?: boolean;
}
export interface JsonTreeData {
/** Data type of the node (e.g. `object`, `array`, `string`, `number`). */
type: string;
/** Unique identifier for the node, derived from its path. */
id: string;
/** Parsed data for the node; an array of child nodes for objects/arrays or the raw value otherwise. */
data: any;
/** Display label for the node. */
label: string;
/** Index of the node within its parent (used for array items). */
index?: number;
}
export declare function parseJsonTree({ id, data, index, label, showEmpty }: ParseJsonInputs): JsonTreeData;