1
0
Fork 0
forked from Mirrors/gomuks

web/jsonview: fix trailing commas in arrays

This commit is contained in:
Tulir Asokan 2024-12-05 16:22:44 +02:00
parent 785f20c7dc
commit 7f30963f5e

View file

@ -42,8 +42,10 @@ function renderJSONValue(data: unknown, collapsed: boolean) {
return <span className="json-collapsed"></span>
}
return <ol className="json-array-children">
{data.map((item, i) =>
<li key={i} className="json-array-entry"><JSONValueWithKey data={item}/></li>)}
{data.map((item, index, arr) =>
<li key={index} className="json-array-entry">
<JSONValueWithKey data={item} trailingComma={index < arr.length - 1}/>
</li>)}
</ol>
} else {
const entries = Object.entries(data)