| name: Node.js Package | ||
| on: | ||
| release: | ||
| types: [created] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20.x' | ||
| registry-url: 'https://registry.npmjs.org' | ||
| - run: npm ci | ||
| - run: npm test | ||
| - run: npm publish | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
+34
-10
@@ -33,3 +33,3 @@ /* | ||
| // | ||
| // v0.8.2 / release 2025.11.23 | ||
| // v0.9.0 / release 2026.01.12 | ||
| // | ||
@@ -47,2 +47,4 @@ // Take to be liten from JSON code to smaller converted characters for like as BASE64. | ||
| // 3. Omit "" (double quote) for variable name definition. | ||
| // 4. Unicode characters is escaped with %uXXXX or %XX format. | ||
| // 5. Single quote ' is not allowed in value of JCODD code when code is fallback(using ' instead " for value container) type. | ||
@@ -95,3 +97,3 @@ class Jcodd { | ||
| let p4 = p3.replace(/([\[\,\:])false([\]\,\}])/g, "$1f$2").replace(/([\[\,\:])false([\]\,\}])/g, "$1f$2"); | ||
| //Rem4ve "" | ||
| //Remove "" | ||
| let p5 = p4.replace(/([\{\,])\"([^\"]*)\"\:/g, "$1$2:"); | ||
@@ -132,3 +134,3 @@ //Check convert unicode | ||
| */ | ||
| static toJson(codd) { | ||
| static toJson(codd, allowFallback = false) { | ||
| switch (codd) { | ||
@@ -141,10 +143,19 @@ case "t": return "true"; | ||
| let p1 = this.unescape(codd);//unescape(codd);//=> deprecated | ||
| //Assign "" | ||
| //Replace ' to " (fallback) | ||
| if (p1.startsWith("'") && p1.endsWith("'")) p1 = '"' + p1.slice(1, -1) + '"'; | ||
| else if (allowFallback) { | ||
| const fallbackRegex = /([\,\[\:])\'([^\']*)\'([\,\]\}])/g; | ||
| if (fallbackRegex.test(p1)) p1 = p1.replace(fallbackRegex, '$1"$2"$3').replace(fallbackRegex, '$1"$2"$3'); | ||
| } | ||
| //Assign property names with "" | ||
| let p2 = p1.replace(/(\{|\}\,|\]\,|\"\,|[eE]?[+\-]?[\d.]+\,|[ntf]\,|true\,|false\,)([^\"\{\}\[\]\,\:]*)\:/g, '$1"$2":'); | ||
| //Convert n to null | ||
| let p3 = p2.replace(/([\[\,\:])n([\]\,\}])/g, "$1null$2").replace(/([\[\,\:])n([\]\,\}])/g, "$1null$2"); | ||
| const nullRegex = /([\[\,\:])n([\]\,\}])/g; | ||
| let p3 = p2.replace(nullRegex, "$1null$2").replace(nullRegex, "$1null$2"); | ||
| //Convert t to true | ||
| let p4 = p3.replace(/([\[\,\:])t([\]\,\}])/g, "$1true$2").replace(/([\[\,\:])t([\]\,\}])/g, "$1true$2"); | ||
| const trueRegex = /([\[\,\:])t([\]\,\}])/g; | ||
| let p4 = p3.replace(trueRegex, "$1true$2").replace(trueRegex, "$1true$2"); | ||
| //Convert f to false | ||
| let p5 = p4.replace(/([\[\,\:])f([\]\,\}])/g, "$1false$2").replace(/([\[\,\:])f([\]\,\}])/g, "$1false$2"); | ||
| const falseRegex = /([\[\,\:])f([\]\,\}])/g; | ||
| let p5 = p4.replace(falseRegex, "$1false$2").replace(falseRegex, "$1false$2"); | ||
@@ -161,6 +172,19 @@ return p5; | ||
| */ | ||
| static parse(codd) { | ||
| let json = this.toJson(codd); | ||
| static parse(codd, allowFallback = true) { | ||
| let json = this.toJson(codd, false); | ||
| return JSON.parse(json); | ||
| try { | ||
| return JSON.parse(json); | ||
| } catch (e) { | ||
| if (allowFallback) { | ||
| // try fallback | ||
| json = this.toJson(codd, true); | ||
| try { | ||
| return JSON.parse(json); | ||
| } catch (ef) { | ||
| throw e; | ||
| } | ||
| } else throw e; | ||
| } | ||
| } | ||
@@ -167,0 +191,0 @@ |
+4
-3
| { | ||
| "name": "jcodd", | ||
| "version": "0.8.2", | ||
| "version": "0.9.0", | ||
| "description": "JSON Characterized Object Data Definition - The JSON based lite code format", | ||
@@ -11,5 +11,6 @@ "main": "jcodd.js", | ||
| "type": "git", | ||
| "url": "https://github.com/Esterkxz/JCODD.git" | ||
| "url": "git+https://github.com/Esterkxz/JCODD.git" | ||
| }, | ||
| "keywords": [ | ||
| "serialization", | ||
| "json", | ||
@@ -24,2 +25,2 @@ "jcodd", | ||
| "license": "MIT" | ||
| } | ||
| } |
+8
-8
@@ -31,3 +31,3 @@ | ||
| ```javascript | ||
| const json = '{"name":"Jane","age":30,"city":"Incheon"}'; | ||
| const json = '{"name":"Jane","age":30,"city":null}'; | ||
| const jcodd = Jcodd.toCodd(json); | ||
@@ -40,3 +40,3 @@ console.log(jcodd); // 압축된 JCODD 형식의 데이터 출력 | ||
| ```javascript | ||
| const jcodd = '...'; // JCODD 형식의 데이터 | ||
| const jcodd = '{name:"Jane",age:30,city:n}'; // JCODD 형식의 데이터 | ||
| const json = Jcodd.toJson(jcodd); | ||
@@ -57,4 +57,4 @@ console.log(json); // 원래의 JSON 데이터 출력 | ||
| ```javascript | ||
| const jcodd = '...'; // JCODD 형식의 데이터 | ||
| const obj = Jcodd.decoddify(jcodd); | ||
| const jcodd = '{name:"Jane",age:30,city:n}'; // JCODD 형식의 데이터 | ||
| const obj = Jcodd.parse(jcodd); | ||
| console.log(obj); // JCODD 형식의 데이터를 객체로 변환하여 출력 | ||
@@ -128,3 +128,3 @@ ``` | ||
| ```javascript | ||
| const json = '{"name":"Jane","age":30,"city":"Incheon"}'; | ||
| const json = '{"name":"Jane","age":30,"city":null}'; | ||
| const jcodd = Jcodd.toCodd(json); | ||
@@ -137,3 +137,3 @@ console.log(jcodd); // Outputs compressed JCODD format data | ||
| ```javascript | ||
| const jcodd = '...'; // JCODD format data | ||
| const jcodd = '{name:"Jane",age:30,city:n}'; // JCODD format data | ||
| const json = Jcodd.toJson(jcodd); | ||
@@ -154,4 +154,4 @@ console.log(json); // Outputs original JSON data | ||
| ```javascript | ||
| const jcodd = '...'; // JCODD format data | ||
| const obj = Jcodd.decoddify(jcodd); | ||
| const jcodd = '{name:"Jane",age:30,city:n}'; // JCODD format data | ||
| const obj = Jcodd.parse(jcodd); | ||
| console.log(obj); // Outputs JCODD format data converted to object | ||
@@ -158,0 +158,0 @@ ``` |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
16327
10.88%5
25%235
10.85%2
Infinity%