From 19c1f002f01ae89460c91065fac9998952eb3f69 Mon Sep 17 00:00:00 2001 From: Juliet Date: Wed, 25 Feb 2026 18:23:59 +0100 Subject: [PATCH] show explicit empty object or array --- src/components/json.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/components/json.tsx b/src/components/json.tsx index 5f3c708..a062398 100644 --- a/src/components/json.tsx +++ b/src/components/json.tsx @@ -168,7 +168,11 @@ const CollapsibleItem = (props: { const isBlobContext = props.parentIsBlob ?? ctx.parentIsBlob; const isObject = () => props.value === Object(props.value); - const isCollapsible = () => isObject() || typeof props.value === "string"; + const isEmpty = () => + Array.isArray(props.value) ? + (props.value as JSONType[]).length === 0 + : Object.keys(props.value as object).length === 0; + const isCollapsible = () => (isObject() && !isEmpty()) || typeof props.value === "string"; const summary = () => { if (typeof props.value === "string") { const len = props.value.length; @@ -188,7 +192,7 @@ const CollapsibleItem = (props: {