(raw: string)
| 37 | * Only allocates a new string when escape sequences are present. |
| 38 | */ |
| 39 | export function unescapeJsonString(raw: string): string { |
| 40 | if (!raw.includes('\\')) return raw |
| 41 | try { |
| 42 | return JSON.parse(`"${raw}"`) |
| 43 | } catch { |
| 44 | return raw |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Extracts a simple JSON string field value from raw text without full parsing. |
no test coverage detected