ConceptPortal-public/rsconcept/frontend/src/components/ui/PrettyJSON.tsx

14 lines
275 B
TypeScript
Raw Normal View History

2023-07-15 17:46:19 +03:00
interface PrettyJsonProps {
2023-12-28 14:04:44 +03:00
data: unknown;
2023-07-15 17:46:19 +03:00
}
/**
* Displays JSON data in a formatted string.
*/
2023-07-25 20:27:29 +03:00
function PrettyJson({ data }: PrettyJsonProps) {
const text = JSON.stringify(data, null, 2);
return <pre>{text === '{}' ? '' : text}</pre>;
2023-07-15 17:46:19 +03:00
}
2023-12-28 14:04:44 +03:00
export default PrettyJson;