setFold(true)} className='jv-chevron' />}
{!fold && jv.enableClipboard && }
{!fold ? (
{node.map((n, i) => (
))}
) : (
)}
{']'}
>
)
} else if (isObject(node)) {
return (
<>
{'{'}
{!fold && setFold(true)} className='jv-chevron' />}
{!fold && jv.enableClipboard && }
{!fold ? (
{Object.entries(node).map(([name, value]) => (
))}
) : (
)}
{'}'}
>
)
}
return null
}
function LongString({ str }: { str: string }) {
if (str.length <= 10) return "{str}"
const [fold, setFold] = useState(true)
return (
setFold(!fold)} className='json-view--string cursor-pointer'>
"{fold ? str.slice(0, 6) + '...' + str.slice(-4) : str}"
)
}
function NameValue({ name, value }: { name: number | string; value: any }) {
return (
{name}:{' '}
)
}
function isObject(node: any) {
return Object.prototype.toString.call(node) === '[object Object]'
}