"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export interface JsonFormatterProps extends React.HTMLAttributes { defaultValue?: string; } /** JSON pretty printer with error line stamp. */ export function JsonFormatter({ defaultValue = '{"section":"C","row":12,"vip":true}', className, ...props }: JsonFormatterProps) { const [raw, setRaw] = React.useState(defaultValue); const [error, setError] = React.useState(null); const format = () => { try { setRaw(JSON.stringify(JSON.parse(raw), null, 2)); setError(null); } catch (e) { setError(e instanceof Error ? e.message : "Invalid JSON"); } }; return (

JSON formatter