Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonrepair

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonrepair - npm Package Compare versions

Comparing version 3.7.0 to 3.7.1

2

lib/cjs/regular/jsonrepair.js

@@ -560,3 +560,3 @@ "use strict";

if (i > start) {
if (text.charCodeAt(i) === _stringUtils.codeOpenParenthesis) {
if (text.charCodeAt(i) === _stringUtils.codeOpenParenthesis && (0, _stringUtils.isFunctionName)(text.slice(start, i).trim())) {
// repair a MongoDB function call like NumberLong("2")

@@ -563,0 +563,0 @@ // repair a JSONP function call like callback({...});

@@ -7,7 +7,7 @@ "use strict";

exports.jsonrepairCore = jsonrepairCore;
var _JSONRepairError = require("../utils/JSONRepairError.js");
var _stringUtils = require("../utils/stringUtils.js");
var _InputBuffer = require("./buffer/InputBuffer.js");
var _OutputBuffer = require("./buffer/OutputBuffer.js");
var _JSONRepairError = require("../utils/JSONRepairError.js");
var _stack = require("./stack.js");
var _stringUtils = require("../utils/stringUtils.js");
const controlCharacters = {

@@ -160,3 +160,3 @@ '\b': '\\b',

i = unquotedStringEnd;
if (skipCharacter(_stringUtils.codeOpenParenthesis)) {
if (skipCharacter(_stringUtils.codeOpenParenthesis) && (0, _stringUtils.isFunctionName)(symbol.trim())) {
// A MongoDB function call like NumberLong("2")

@@ -163,0 +163,0 @@ // Or a JSONP function call like callback({...});

@@ -15,2 +15,3 @@ "use strict";

exports.isDoubleQuoteLike = isDoubleQuoteLike;
exports.isFunctionName = isFunctionName;
exports.isHex = isHex;

@@ -183,2 +184,5 @@ exports.isQuote = isQuote;

}
function isFunctionName(text) {
return /^\w+$/.test(text);
}
//# sourceMappingURL=stringUtils.js.map
import { JSONRepairError } from '../utils/JSONRepairError.js';
import { codeAsterisk, codeBackslash, codeCloseParenthesis, codeClosingBrace, codeClosingBracket, codeColon, codeComma, codeDot, codeDoubleQuote, codeLowercaseE, codeMinus, codeNewline, codeOpeningBrace, codeOpeningBracket, codeOpenParenthesis, codePlus, codeSemicolon, codeSlash, codeUppercaseE, endsWithCommaOrNewline, insertBeforeLastWhitespace, isControlCharacter, isDelimiter, isDelimiterExceptSlash, isDigit, isDoubleQuote, isDoubleQuoteLike, isHex, isQuote, isSingleQuote, isSingleQuoteLike, isSpecialWhitespace, isStartOfValue, isValidStringCharacter, isWhitespace, removeAtIndex, stripLastOccurrence } from '../utils/stringUtils.js';
import { codeAsterisk, codeBackslash, codeCloseParenthesis, codeClosingBrace, codeClosingBracket, codeColon, codeComma, codeDot, codeDoubleQuote, codeLowercaseE, codeMinus, codeNewline, codeOpeningBrace, codeOpeningBracket, codeOpenParenthesis, codePlus, codeSemicolon, codeSlash, codeUppercaseE, endsWithCommaOrNewline, insertBeforeLastWhitespace, isControlCharacter, isDelimiter, isDelimiterExceptSlash, isDigit, isDoubleQuote, isDoubleQuoteLike, isFunctionName, isHex, isQuote, isSingleQuote, isSingleQuoteLike, isSpecialWhitespace, isStartOfValue, isValidStringCharacter, isWhitespace, removeAtIndex, stripLastOccurrence } from '../utils/stringUtils.js';
const controlCharacters = {

@@ -554,3 +554,3 @@ '\b': '\\b',

if (i > start) {
if (text.charCodeAt(i) === codeOpenParenthesis) {
if (text.charCodeAt(i) === codeOpenParenthesis && isFunctionName(text.slice(start, i).trim())) {
// repair a MongoDB function call like NumberLong("2")

@@ -557,0 +557,0 @@ // repair a JSONP function call like callback({...});

@@ -0,6 +1,6 @@

import { JSONRepairError } from '../utils/JSONRepairError.js';
import { codeAsterisk, codeBackslash, codeCloseParenthesis, codeClosingBrace, codeClosingBracket, codeColon, codeComma, codeDot, codeDoubleQuote, codeLowercaseE, codeMinus, codeNewline, codeOpeningBrace, codeOpeningBracket, codeOpenParenthesis, codePlus, codeSemicolon, codeSlash, codeUppercaseE, isControlCharacter, isDelimiter, isDelimiterExceptSlash, isDigit, isDoubleQuote, isDoubleQuoteLike, isFunctionName, isHex, isQuote, isSingleQuote, isSingleQuoteLike, isSpecialWhitespace, isStartOfValue, isValidStringCharacter, isWhitespace } from '../utils/stringUtils.js';
import { createInputBuffer } from './buffer/InputBuffer.js';
import { createOutputBuffer } from './buffer/OutputBuffer.js';
import { JSONRepairError } from '../utils/JSONRepairError.js';
import { Caret, createStack, StackType } from './stack.js';
import { codeAsterisk, codeBackslash, codeCloseParenthesis, codeClosingBrace, codeClosingBracket, codeColon, codeComma, codeDot, codeDoubleQuote, codeLowercaseE, codeMinus, codeNewline, codeOpeningBrace, codeOpeningBracket, codeOpenParenthesis, codePlus, codeSemicolon, codeSlash, codeUppercaseE, isControlCharacter, isDelimiter, isDelimiterExceptSlash, isDigit, isDoubleQuote, isDoubleQuoteLike, isHex, isQuote, isSingleQuote, isSingleQuoteLike, isSpecialWhitespace, isStartOfValue, isValidStringCharacter, isWhitespace } from '../utils/stringUtils.js';
const controlCharacters = {

@@ -153,3 +153,3 @@ '\b': '\\b',

i = unquotedStringEnd;
if (skipCharacter(codeOpenParenthesis)) {
if (skipCharacter(codeOpenParenthesis) && isFunctionName(symbol.trim())) {
// A MongoDB function call like NumberLong("2")

@@ -156,0 +156,0 @@ // Or a JSONP function call like callback({...});

@@ -158,2 +158,5 @@ export const codeBackslash = 0x5c; // "\"

}
export function isFunctionName(text) {
return /^\w+$/.test(text);
}
//# sourceMappingURL=stringUtils.js.map

@@ -84,2 +84,3 @@ export declare const codeBackslash = 92;

export declare function endsWithCommaOrNewline(text: string): boolean;
export declare function isFunctionName(text: string): boolean;
//# sourceMappingURL=stringUtils.d.ts.map

@@ -171,2 +171,5 @@ (function (global, factory) {

}
function isFunctionName(text) {
return /^\w+$/.test(text);
}

@@ -724,3 +727,3 @@ const controlCharacters = {

if (i > start) {
if (text.charCodeAt(i) === codeOpenParenthesis) {
if (text.charCodeAt(i) === codeOpenParenthesis && isFunctionName(text.slice(start, i).trim())) {
// repair a MongoDB function call like NumberLong("2")

@@ -727,0 +730,0 @@ // repair a JSONP function call like callback({...});

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).JSONRepair={})}(this,function(t){"use strict";class x extends Error{constructor(t,e){super(t+" at position "+e),this.position=e}}const a=125,e=32,y=10,O=9,N=13,J=8,S=12,j=34,r=39,k=48,I=57,T=65,$=97,m=70,E=102,h=160,d=8192,l=8202,R=8239,U=8287,F=12288,n=8220,o=8221,c=8216,i=8217,f=96,u=180;function q(t){return t>=k&&t<=I}function z(t){return s.test(t)}const s=/^[,:[\]/{}()\n+]$/;function B(t){return A.test(t)||t&&G(t.charCodeAt(0))}const A=/^[[{\w-]$/;function D(t){return t===e||t===y||t===O||t===N}function G(t){return H(t)||L(t)}function H(t){return t===j||t===n||t===o}function K(t){return t===j}function L(t){return t===r||t===c||t===i||t===f||t===u}function M(t){return t===r}function P(t,e,r){r=2<arguments.length&&void 0!==r&&r,e=t.lastIndexOf(e);return-1!==e?t.substring(0,e)+(r?"":t.substring(e+1)):t}function Q(t,e){let r=t.length;if(!D(t.charCodeAt(r-1)))return t+e;for(;D(t.charCodeAt(r-1));)r--;return t.substring(0,r)+e+t.substring(r)}const V={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},W={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};t.JSONRepairError=x,t.jsonrepair=function(s){let A=0,C="";if(!c())throw new x("Unexpected end of json string",s.length);var t=i(44);if(t&&g(),B(s[A])&&/[,\n][ \t\r]*$/.test(C)){t||(C=Q(C,","));{let t=!0,e=!0;for(;e;)t?t=!1:i(44)||(C=Q(C,",")),e=c();e||(C=P(C,","));C="[\n".concat(C,"\n]")}}else t&&(C=P(C,","));for(;s.charCodeAt(A)===a||93===s.charCodeAt(A);)A++,g();if(A>=s.length)return C;throw new x("Unexpected character "+JSON.stringify(s[A]),A);function c(){g();var t=function(){if(123!==s.charCodeAt(A))return!1;{C+="{",A++,g();let e=!0;for(;A<s.length&&s.charCodeAt(A)!==a;){let t;if(e?(t=!0,e=!1):((t=i(44))||(C=Q(C,",")),g()),!(b()||f())){s.charCodeAt(A)===a||123===s.charCodeAt(A)||93===s.charCodeAt(A)||91===s.charCodeAt(A)||void 0===s[A]?C=P(C,","):function(){throw new x("Object key expected",A)}();break}g();var r=i(58),n=A>=s.length,o=(r||(B(s[A])||n?C=Q(C,":"):u()),c());o||(r||n?C+="null":u())}return s.charCodeAt(A)===a?(C+="}",A++):C=Q(C,"}"),!0}}()||function(){if(91!==s.charCodeAt(A))return!1;{C+="[",A++,g();let t=!0;for(;A<s.length&&93!==s.charCodeAt(A);){t?t=!1:i(44)||(C=Q(C,","));var e=c();if(!e){C=P(C,",");break}}return 93===s.charCodeAt(A)?(C+="]",A++):C=Q(C,"]"),!0}}()||b()||function(){var t=A;if(45===s.charCodeAt(A)){if(A++,n())return o(t),!0;if(!q(s.charCodeAt(A)))return A=t,!1}for(;q(s.charCodeAt(A));)A++;if(46===s.charCodeAt(A)){if(A++,n())return o(t),!0;if(!q(s.charCodeAt(A)))return A=t,!1;for(;q(s.charCodeAt(A));)A++}if(101===s.charCodeAt(A)||69===s.charCodeAt(A)){if(A++,45!==s.charCodeAt(A)&&43!==s.charCodeAt(A)||A++,n())return o(t),!0;if(!q(s.charCodeAt(A)))return A=t,!1;for(;q(s.charCodeAt(A));)A++}var e,r;if(n()){if(A>t)return e=s.slice(t,A),r=/^0\d/.test(e),C+=r?'"'.concat(e,'"'):e,!0}else A=t;return!1}()||r("true","true")||r("false","false")||r("null","null")||r("True","true")||r("False","false")||r("None","null")||f();return g(),t}function g(){A;let t=e();for(;t=(t=function(){if(47===s.charCodeAt(A)&&42===s.charCodeAt(A+1)){for(;A<s.length&&!function(t,e){return"*"===t[e]&&"/"===t[e+1]}(s,A);)A++;A+=2}else{if(47!==s.charCodeAt(A)||47!==s.charCodeAt(A+1))return!1;for(;A<s.length&&s.charCodeAt(A)!==y;)A++}return!0}())&&e(););A}function e(){let t="";for(var e,r;(e=D(s.charCodeAt(A)))||(r=s.charCodeAt(A))===h||r>=d&&r<=l||r===R||r===U||r===F;)t+=e?s[A]:" ",A++;return 0<t.length&&(C+=t,!0)}function i(t){return s.charCodeAt(A)===t&&(C+=s[A],A++,!0)}function v(){92===s.charCodeAt(A)&&A++}function b(t){var r,n,o=0<arguments.length&&void 0!==t&&t;let c=92===s.charCodeAt(A);if(c&&(A++,c=!0),G(s.charCodeAt(A))){var i=K(s.charCodeAt(A))?K:M(s.charCodeAt(A))?M:L(s.charCodeAt(A))?L:H,f=A,u=C.length;let e='"';for(A++;;){if(A>=s.length)return a=w(A-1),!o&&z(s.charAt(a))?(A=f,C=C.substring(0,u),b(!0)):(e=Q(e,'"'),C+=e,!0);if(i(s.charCodeAt(A))){var a=A,h=e.length;if(e+='"',A++,C+=e,g(),o||A>=s.length||z(s.charAt(A))||G(s.charCodeAt(A))||q(s.charCodeAt(A)))return p(),!0;if(z(s.charAt(w(a-1))))return A=f,C=C.substring(0,u),b(!0);C=C.substring(0,u),A=a+1,e=e.substring(0,h)+"\\"+e.substring(h)}else{if(o&&z(s[A]))return e=Q(e,'"'),C+=e,p(),!0;if(92===s.charCodeAt(A)){h=s.charAt(A+1);if(void 0!==W[h])e+=s.slice(A,A+2),A+=2;else if("u"===h){let t=2;for(;t<6&&((n=s.charCodeAt(A+t))>=k&&n<=I||n>=T&&n<=m||n>=$&&n<=E);)t++;if(6===t)e+=s.slice(A,A+6),A+=6;else{if(!(A+t>=s.length))throw d=void 0,d=s.slice(A,A+6),new x('Invalid unicode character "'.concat(d,'"'),A);A=s.length}}else e+=h,A+=2}else{var d=s.charAt(A),l=s.charCodeAt(A);if(l===j&&92!==s.charCodeAt(A-1))e+="\\"+d;else if((r=l)===y||r===N||r===O||r===J||r===S)e+=V[d];else{if(!(32<=(r=l)&&r<=1114111))throw l=void 0,l=d,new x("Invalid character "+JSON.stringify(l),A);e+=d}A++}}c&&v()}}return!1}function p(){let t=!1;for(g();43===s.charCodeAt(A);){t=!0,A++,g();var e=(C=P(C,'"',!0)).length,r=b();C=r?(r=C,e=e,n=1,r.substring(0,e)+r.substring(e+n)):Q(C,'"')}var n;t}function r(t,e){return s.slice(A,A+t.length)===t&&(C+=e,A+=t.length,!0)}function f(){for(var t,e=A;A<s.length&&(!z(t=s[A])||"/"===t)&&!G(s.charCodeAt(A));)A++;if(A>e){if(40===s.charCodeAt(A))A++,c(),41===s.charCodeAt(A)&&(A++,59===s.charCodeAt(A))&&A++;else{for(;D(s.charCodeAt(A-1))&&0<A;)A--;e=s.slice(e,A);C+="undefined"===e?"null":JSON.stringify(e),s.charCodeAt(A)===j&&A++}return!0}}function w(t){let e=t;for(;0<e&&D(s.charCodeAt(e));)e--;return e}function n(){return A>=s.length||z(s[A])||D(s.charCodeAt(A))}function o(t){C+=s.slice(t,A)+"0"}function u(){throw new x("Colon expected",A)}}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).JSONRepair={})}(this,function(t){"use strict";class x extends Error{constructor(t,e){super(t+" at position "+e),this.position=e}}const a=125,e=32,y=10,O=9,N=13,J=8,S=12,j=34,r=39,$=48,k=57,m=65,I=97,T=70,E=102,h=160,d=8192,l=8202,R=8239,U=8287,F=12288,n=8220,o=8221,c=8216,i=8217,f=96,u=180;function q(t){return t>=$&&t<=k}function z(t){return s.test(t)}const s=/^[,:[\]/{}()\n+]$/;function B(t){return A.test(t)||t&&G(t.charCodeAt(0))}const A=/^[[{\w-]$/;function D(t){return t===e||t===y||t===O||t===N}function G(t){return H(t)||L(t)}function H(t){return t===j||t===n||t===o}function K(t){return t===j}function L(t){return t===r||t===c||t===i||t===f||t===u}function M(t){return t===r}function P(t,e,r){r=2<arguments.length&&void 0!==r&&r,e=t.lastIndexOf(e);return-1!==e?t.substring(0,e)+(r?"":t.substring(e+1)):t}function Q(t,e){let r=t.length;if(!D(t.charCodeAt(r-1)))return t+e;for(;D(t.charCodeAt(r-1));)r--;return t.substring(0,r)+e+t.substring(r)}const V={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},W={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};t.JSONRepairError=x,t.jsonrepair=function(s){let A=0,C="";if(!c())throw new x("Unexpected end of json string",s.length);var t=i(44);if(t&&g(),B(s[A])&&/[,\n][ \t\r]*$/.test(C)){t||(C=Q(C,","));{let t=!0,e=!0;for(;e;)t?t=!1:i(44)||(C=Q(C,",")),e=c();e||(C=P(C,","));C="[\n".concat(C,"\n]")}}else t&&(C=P(C,","));for(;s.charCodeAt(A)===a||93===s.charCodeAt(A);)A++,g();if(A>=s.length)return C;throw new x("Unexpected character "+JSON.stringify(s[A]),A);function c(){g();var t=function(){if(123!==s.charCodeAt(A))return!1;{C+="{",A++,g();let e=!0;for(;A<s.length&&s.charCodeAt(A)!==a;){let t;if(e?(t=!0,e=!1):((t=i(44))||(C=Q(C,",")),g()),!(b()||f())){s.charCodeAt(A)===a||123===s.charCodeAt(A)||93===s.charCodeAt(A)||91===s.charCodeAt(A)||void 0===s[A]?C=P(C,","):function(){throw new x("Object key expected",A)}();break}g();var r=i(58),n=A>=s.length,o=(r||(B(s[A])||n?C=Q(C,":"):u()),c());o||(r||n?C+="null":u())}return s.charCodeAt(A)===a?(C+="}",A++):C=Q(C,"}"),!0}}()||function(){if(91!==s.charCodeAt(A))return!1;{C+="[",A++,g();let t=!0;for(;A<s.length&&93!==s.charCodeAt(A);){t?t=!1:i(44)||(C=Q(C,","));var e=c();if(!e){C=P(C,",");break}}return 93===s.charCodeAt(A)?(C+="]",A++):C=Q(C,"]"),!0}}()||b()||function(){var t=A;if(45===s.charCodeAt(A)){if(A++,n())return o(t),!0;if(!q(s.charCodeAt(A)))return A=t,!1}for(;q(s.charCodeAt(A));)A++;if(46===s.charCodeAt(A)){if(A++,n())return o(t),!0;if(!q(s.charCodeAt(A)))return A=t,!1;for(;q(s.charCodeAt(A));)A++}if(101===s.charCodeAt(A)||69===s.charCodeAt(A)){if(A++,45!==s.charCodeAt(A)&&43!==s.charCodeAt(A)||A++,n())return o(t),!0;if(!q(s.charCodeAt(A)))return A=t,!1;for(;q(s.charCodeAt(A));)A++}var e,r;if(n()){if(A>t)return e=s.slice(t,A),r=/^0\d/.test(e),C+=r?'"'.concat(e,'"'):e,!0}else A=t;return!1}()||r("true","true")||r("false","false")||r("null","null")||r("True","true")||r("False","false")||r("None","null")||f();return g(),t}function g(){A;let t=e();for(;t=(t=function(){if(47===s.charCodeAt(A)&&42===s.charCodeAt(A+1)){for(;A<s.length&&!function(t,e){return"*"===t[e]&&"/"===t[e+1]}(s,A);)A++;A+=2}else{if(47!==s.charCodeAt(A)||47!==s.charCodeAt(A+1))return!1;for(;A<s.length&&s.charCodeAt(A)!==y;)A++}return!0}())&&e(););A}function e(){let t="";for(var e,r;(e=D(s.charCodeAt(A)))||(r=s.charCodeAt(A))===h||r>=d&&r<=l||r===R||r===U||r===F;)t+=e?s[A]:" ",A++;return 0<t.length&&(C+=t,!0)}function i(t){return s.charCodeAt(A)===t&&(C+=s[A],A++,!0)}function v(){92===s.charCodeAt(A)&&A++}function b(t){var r,n,o=0<arguments.length&&void 0!==t&&t;let c=92===s.charCodeAt(A);if(c&&(A++,c=!0),G(s.charCodeAt(A))){var i=K(s.charCodeAt(A))?K:M(s.charCodeAt(A))?M:L(s.charCodeAt(A))?L:H,f=A,u=C.length;let e='"';for(A++;;){if(A>=s.length)return a=w(A-1),!o&&z(s.charAt(a))?(A=f,C=C.substring(0,u),b(!0)):(e=Q(e,'"'),C+=e,!0);if(i(s.charCodeAt(A))){var a=A,h=e.length;if(e+='"',A++,C+=e,g(),o||A>=s.length||z(s.charAt(A))||G(s.charCodeAt(A))||q(s.charCodeAt(A)))return p(),!0;if(z(s.charAt(w(a-1))))return A=f,C=C.substring(0,u),b(!0);C=C.substring(0,u),A=a+1,e=e.substring(0,h)+"\\"+e.substring(h)}else{if(o&&z(s[A]))return e=Q(e,'"'),C+=e,p(),!0;if(92===s.charCodeAt(A)){h=s.charAt(A+1);if(void 0!==W[h])e+=s.slice(A,A+2),A+=2;else if("u"===h){let t=2;for(;t<6&&((n=s.charCodeAt(A+t))>=$&&n<=k||n>=m&&n<=T||n>=I&&n<=E);)t++;if(6===t)e+=s.slice(A,A+6),A+=6;else{if(!(A+t>=s.length))throw d=void 0,d=s.slice(A,A+6),new x('Invalid unicode character "'.concat(d,'"'),A);A=s.length}}else e+=h,A+=2}else{var d=s.charAt(A),l=s.charCodeAt(A);if(l===j&&92!==s.charCodeAt(A-1))e+="\\"+d;else if((r=l)===y||r===N||r===O||r===J||r===S)e+=V[d];else{if(!(32<=(r=l)&&r<=1114111))throw l=void 0,l=d,new x("Invalid character "+JSON.stringify(l),A);e+=d}A++}}c&&v()}}return!1}function p(){let t=!1;for(g();43===s.charCodeAt(A);){t=!0,A++,g();var e=(C=P(C,'"',!0)).length,r=b();C=r?(r=C,e=e,n=1,r.substring(0,e)+r.substring(e+n)):Q(C,'"')}var n;t}function r(t,e){return s.slice(A,A+t.length)===t&&(C+=e,A+=t.length,!0)}function f(){for(var t,e=A;A<s.length&&(!z(t=s[A])||"/"===t)&&!G(s.charCodeAt(A));)A++;if(A>e){if(40===s.charCodeAt(A)&&/^\w+$/.test(s.slice(e,A).trim()))A++,c(),41===s.charCodeAt(A)&&(A++,59===s.charCodeAt(A))&&A++;else{for(;D(s.charCodeAt(A-1))&&0<A;)A--;e=s.slice(e,A);C+="undefined"===e?"null":JSON.stringify(e),s.charCodeAt(A)===j&&A++}return!0}}function w(t){let e=t;for(;0<e&&D(s.charCodeAt(e));)e--;return e}function n(){return A>=s.length||z(s[A])||D(s.charCodeAt(A))}function o(t){C+=s.slice(t,A)+"0"}function u(){throw new x("Colon expected",A)}}});
{
"name": "jsonrepair",
"version": "3.7.0",
"version": "3.7.1",
"description": "Repair broken JSON documents",

@@ -5,0 +5,0 @@ "repository": {

@@ -47,2 +47,4 @@ # jsonrepair

### ES module
Use the `jsonrepair` function using an ES modules import:

@@ -67,2 +69,4 @@

### Streaming API
Use the streaming API in Node.js:

@@ -94,2 +98,4 @@

### CommonJS
Use in CommonJS (not recommended):

@@ -103,2 +109,4 @@

### UMD
Use with UMD in the browser (not recommended):

@@ -115,7 +123,25 @@

### Python
### API
Use in Python via [`PythonMonkey`](https://github.com/Distributive-Network/PythonMonkey#pythonmonkey).
#### Regular API
1. Install `jsonrepair` via `npm install jsonrepair`
2. Install `PythonMonkey` via `pip install pythonmonkey`
3. Use the libraries in a Python script:
```python
import pythonmonkey
jsonrepair = pythonmonkey.require('jsonrepair').jsonrepair
json = "[1,2,3,"
repaired = jsonrepair(json)
print(repaired)
# [1,2,3]
```
## API
### Regular API
You can use `jsonrepair` as a function or as a streaming transform. Broken JSON is passed to the function, and the function either returns the repaired JSON, or throws an `JSONRepairError` exception when an issue is encountered which could not be solved.

@@ -128,3 +154,3 @@

#### Streaming API
### Streaming API

@@ -141,3 +167,3 @@ The streaming API is availabe in `jsonrepair/stream` and can be used in a [Node.js stream](https://nodejs.org/api/stream.html). It consists of a transform function that can be used in a stream pipeline.

### Command Line Interface (CLI)
## Command Line Interface (CLI)

@@ -177,3 +203,3 @@ When `jsonrepair` is installed globally using npm, it can be used on the command line. To install `jsonrepair` globally:

### Alternatives:
## Alternatives:

@@ -184,3 +210,3 @@ Similar libraries:

### Develop
## Develop

@@ -194,59 +220,17 @@ When implementing a fix or a new feature, it important to know that there are currently two implementations:

To build the library (ESM, CommonJs, and UMD output in the folder `lib`):
Scripts:
```
$ npm install
$ npm run build
```
Script | Description
---------- | -----------
`npm install` | Install the dependencies once
`npm run build` | Build the library (ESM, CommonJs, and UMD output in the folder `lib`)
`npm test` | Run the unit tests
`npm run lint` | Run the linter (eslint)
`npm run format` | Automatically fix linter issues
`npm run build-and-test` | Run the linter, build all, and run unit tests and integration tests
`npm run release` | Release a new version. This will lint, test, build, increment the version number, push the changes to git, add a git version tag, and publish the npm package.
`npm run release-dry-run` | Run all release steps and see the change list without actually publishing:
To run the unit tests:
```
$ npm test
```
To run the linter (eslint):
```
$ npm run lint
```
To automatically fix linter issues:
```
$ npm run format
```
To run the linter, build all, and run unit tests and integration tests:
```
$ npm run build-and-test
```
### Release
To release a new version:
```
$ npm run release
```
This will:
- lint
- test
- build
- increment the version number
- push the changes to git, add a git version tag
- publish the npm package
To try the build and see the change list without actually publishing:
```
$ npm run release-dry-run
```
## License
Released under the [ISC license](LICENSE.md).

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc