(text)
| 1791 | } |
| 1792 | |
| 1793 | function normalizeLooseJSONSource(text) { |
| 1794 | let fixed = String(text).trim(); |
| 1795 | |
| 1796 | fixed = replaceOutsideQuotedSegments(fixed, /([\{,]\s*)'([^'\\]*?)'(\s*:)/g, function (match, prefix, key, suffix) { |
| 1797 | return prefix + '"' + key + '"' + suffix; |
| 1798 | }); |
| 1799 | fixed = replaceOutsideQuotedSegments(fixed, /([\{,]\s*)(\w+)(\s*:)/g, function (match, prefix, key, suffix) { |
| 1800 | return prefix + '"' + key + '"' + suffix; |
| 1801 | }); |
| 1802 | fixed = replaceOutsideQuotedSegments(fixed, /(:\s*)'([^'\\]*?)'/g, function (match, prefix, value) { |
| 1803 | return prefix + '"' + value + '"'; |
| 1804 | }); |
| 1805 | |
| 1806 | return fixed; |
| 1807 | } |
| 1808 | |
| 1809 | // 统一的 BigInt 安全解析(与 json-auto-utils/format-lib/worker 思路一致): |
| 1810 | // 1) 只在引号外修正宽松 key;2) 为可能的超长数字加标记;3) 用 reviver 还原为 BigInt |
no test coverage detected