JsonViewer
Text-only <details> JSON tree: lazy children, paging, cycle and hostile-key safety, copy path and value, host edit actions.
beta
Examples
Api response
response
id "req_9f3a21" string
status 200 number
model "gateway-large" string
usage
lanes
cached false boolean
<script lang="ts">
import JsonViewer from '@tcpsystems/ui/foundation/JsonViewer';
const response = {
id: 'req_9f3a21',
status: 200,
model: 'gateway-large',
usage: { prompt_tokens: 1204, completion_tokens: 318 },
lanes: ['primary', 'fallback'],
cached: false
};
</script>
<JsonViewer value={response} label="response" />Open depth
config
server
port 8080 number
tls
enabled true boolean
minVersion "1.3" string
database
host "127.0.0.1" string
port 5000 number
pool
min 2 number
max 20 number
features
streaming true boolean
audit true boolean
<script lang="ts">
import JsonViewer from '@tcpsystems/ui/foundation/JsonViewer';
const config = {
server: { port: 8080, tls: { enabled: true, minVersion: '1.3' } },
database: { host: '127.0.0.1', port: 5000, pool: { min: 2, max: 20 } },
features: { streaming: true, audit: true }
};
</script>
<JsonViewer value={config} label="config" openDepth={3} />Paged array
events
0
1
2
3
4
<script lang="ts">
import JsonViewer from '@tcpsystems/ui/foundation/JsonViewer';
const events = Array.from({ length: 25 }, (_, i) => ({ seq: i + 1, type: i % 5 === 0 ? 'deploy' : 'request', ok: i % 7 !== 0 }));
</script>
<JsonViewer value={events} label="events" pageSize={5} />Edge cases
record
name "gateway-vnext" string
note "A long description …t on the platform." string
empty { } object
none null null
self [Circular] circular
<script lang="ts">
import JsonViewer from '@tcpsystems/ui/foundation/JsonViewer';
const record: Record<string, unknown> = {
name: 'gateway-vnext',
note: 'A long description that explains in detail how this release changes request routing for every tenant on the platform.',
empty: {},
none: null
};
record.self = record;
</script>
<JsonViewer value={record} label="record" maxLength={40} openDepth={2} />API
import JsonViewer from '@tcpsystems/ui/foundation/JsonViewer';| Prop | Type | Default |
|---|---|---|
value? | native | none |
label? | native | 'root' |
openDepth? | native | 1 |
pageSize? | native | 100 |
maxLength? | native | 120 |
copyPathLabel? | string | 'Copy path' |
copyValueLabel? | string | 'Copy value' |
circularLabel? | string | '[Circular]' |
unreadableLabel? | string | '[Unreadable]' |
moreLabel? | (remaining: number) => string | (n: number) => `Show ${Math.min(n, pageSize)} more of ${n}` |
actions? | native | none |
track? | native | none |
| Hook | Kind |
|---|---|
.tcp-json-viewer | Root class |
data-kind | Data attribute |