| 11 | const [error, setError] = useState('') |
| 12 | |
| 13 | const handleConfirm = () => { |
| 14 | try { |
| 15 | const parsedJSON = JSON.parse(jsonInput) |
| 16 | if (!Array.isArray(parsedJSON)) throw new Error('Input must be an array of properties') |
| 17 | const formattedData = parsedJSON.map((item, index) => ({ |
| 18 | id: index + 1, |
| 19 | property: item.property || '', |
| 20 | type: item.type || 'string', |
| 21 | description: item.description || '', |
| 22 | required: item.required || false |
| 23 | })) |
| 24 | onConfirm(formattedData) |
| 25 | setError('') |
| 26 | } catch (err) { |
| 27 | setError('Invalid JSON format. Please check your input.') |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | const exampleJSON = `[ |
| 32 | { |