the-forest/client/src/page/components/JsonDisplay.jsx

15 lines
460 B
JavaScript

function JsonDisplay({obj}) {
if (!obj)
return <section className="page-contents">No additional attributes found.</section>;
let empty = true;
for (const prop in obj) {
if (Object.hasOwn(obj, prop) && obj[prop] !== undefined) empty = false;
}
if (empty)
return <section className="page-contents">No additional attributes found.</section>;
return <section className="page-contents">{JSON.stringify(obj)}</section>;
}
export default JsonDisplay;