(value: unknown)
| 164 | * original value if parsing fails. |
| 165 | */ |
| 166 | const tryParseJson = (value: unknown): unknown => { |
| 167 | if (typeof value !== 'string') return value |
| 168 | try { |
| 169 | const trimmed = value.trim() |
| 170 | if ( |
| 171 | (trimmed.startsWith('[') && trimmed.endsWith(']')) || |
| 172 | (trimmed.startsWith('{') && trimmed.endsWith('}')) |
| 173 | ) { |
| 174 | return JSON.parse(trimmed) |
| 175 | } |
| 176 | } catch { |
| 177 | return value |
| 178 | } |
| 179 | return value |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Formats a subblock value for display, intelligently handling nested |
no test coverage detected