(json: string | null | undefined)
| 63 | * which support comments and other jsonc features. |
| 64 | */ |
| 65 | export function safeParseJSONC(json: string | null | undefined): unknown { |
| 66 | if (!json) { |
| 67 | return null |
| 68 | } |
| 69 | try { |
| 70 | // Strip BOM before parsing - PowerShell 5.x adds BOM to UTF-8 files |
| 71 | return parseJsonc(stripBOM(json)) |
| 72 | } catch (e) { |
| 73 | logError(e) |
| 74 | return null |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Modify a jsonc string by adding a new item to an array, preserving comments and formatting. |
no test coverage detected