(value: any)
| 469 | return helpfulMessage |
| 470 | } |
| 471 | function parseJSON(value: any): { parsed: any; error: string | null } { |
| 472 | if (typeof value !== 'string') { |
| 473 | return { parsed: value, error: null }; |
| 474 | } |
| 475 | |
| 476 | const trimmedValue = value.trim(); |
| 477 | if (trimmedValue === '') { |
| 478 | return { parsed: null, error: null }; |
| 479 | } |
| 480 | |
| 481 | try { |
| 482 | const parsed = JSON.parse(trimmedValue); |
| 483 | return { parsed, error: null }; |
| 484 | } catch (e: any) { |
| 485 | // Provide helpful error messages based on common JSON mistakes |
| 486 | let helpfulMessage = createHelpfulJsonError(e, trimmedValue) |
| 487 | |
| 488 | return { parsed: null, error: helpfulMessage }; |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | class Controls { |
| 493 | private isSectionControl = false; |
no test coverage detected