diff --git a/components.d.ts b/components.d.ts
index 3e65c3cc5..ef0d74d72 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -131,17 +131,22 @@ declare module '@vue/runtime-core' {
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
NCheckbox: typeof import('naive-ui')['NCheckbox']
+ NCode: typeof import('naive-ui')['NCode']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDivider: typeof import('naive-ui')['NDivider']
NEllipsis: typeof import('naive-ui')['NEllipsis']
+ NFormItem: typeof import('naive-ui')['NFormItem']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
+ NInputNumber: typeof import('naive-ui')['NInputNumber']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
+ NScrollbar: typeof import('naive-ui')['NScrollbar']
NSpace: typeof import('naive-ui')['NSpace']
+ NSwitch: typeof import('naive-ui')['NSwitch']
NTable: typeof import('naive-ui')['NTable']
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
diff --git a/package.json b/package.json
index 5738b6325..c670977d2 100644
--- a/package.json
+++ b/package.json
@@ -72,6 +72,7 @@
"ibantools": "^4.3.3",
"js-base64": "^3.7.6",
"json5": "^2.2.3",
+ "jsonrepair": "^3.12.0",
"jwt-decode": "^3.1.2",
"libphonenumber-js": "^1.10.28",
"lodash": "^4.17.21",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5d1138932..5db7553b1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -49,7 +49,7 @@ importers:
version: 10.3.0(vue@3.3.4)
'@vueuse/head':
specifier: ^1.0.0
- version: 1.0.0(typescript@5.2.2)(vue@3.3.4)
+ version: 1.0.0(vue@3.3.4)
'@vueuse/router':
specifier: ^10.0.0
version: 10.0.0(vue-router@4.1.6(vue@3.3.4))(vue@3.3.4)
@@ -113,6 +113,9 @@ importers:
json5:
specifier: ^2.2.3
version: 2.2.3
+ jsonrepair:
+ specifier: ^3.12.0
+ version: 3.12.0
jwt-decode:
specifier: ^3.1.2
version: 3.1.2
@@ -2303,9 +2306,6 @@ packages:
'@vue/compiler-core@3.3.7':
resolution: {integrity: sha512-pACdY6YnTNVLXsB86YD8OF9ihwpolzhhtdLVHhBL6do/ykr6kKXNYABRtNMGrsQXpEXXyAdwvWWkuTbs4MFtPQ==}
- '@vue/compiler-core@3.5.13':
- resolution: {integrity: sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==}
-
'@vue/compiler-dom@3.2.47':
resolution: {integrity: sha512-dBBnEHEPoftUiS03a4ggEig74J2YBZ2UIeyfpcRM2tavgMWo4bsEfgCGsu+uJIL/vax9S+JztH8NmQerUo7shQ==}
@@ -2315,18 +2315,12 @@ packages:
'@vue/compiler-dom@3.3.7':
resolution: {integrity: sha512-0LwkyJjnUPssXv/d1vNJ0PKfBlDoQs7n81CbO6Q0zdL7H1EzqYRrTVXDqdBVqro0aJjo/FOa1qBAPVI4PGSHBw==}
- '@vue/compiler-dom@3.5.13':
- resolution: {integrity: sha512-ZOJ46sMOKUjO3e94wPdCzQ6P1Lx/vhp2RSvfaab88Ajexs0AHeV0uasYhi99WPaogmBlRHNRuly8xV75cNTMDA==}
-
'@vue/compiler-sfc@3.2.47':
resolution: {integrity: sha512-rog05W+2IFfxjMcFw10tM9+f7i/+FFpZJJ5XHX72NP9eC2uRD+42M3pYcQqDXVYoj74kHMSEdQ/WmCjt8JFksQ==}
'@vue/compiler-sfc@3.3.4':
resolution: {integrity: sha512-6y/d8uw+5TkCuzBkgLS0v3lSM3hJDntFEiUORM11pQ/hKvkhSKZrXW6i69UyXlJQisJxuUEJKAWEqWbWsLeNKQ==}
- '@vue/compiler-sfc@3.5.13':
- resolution: {integrity: sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==}
-
'@vue/compiler-ssr@3.2.47':
resolution: {integrity: sha512-wVXC+gszhulcMD8wpxMsqSOpvDZ6xKXSVWkf50Guf/S+28hTAXPDYRTbLQ3EDkOP5Xz/+SY37YiwDquKbJOgZw==}
@@ -2336,9 +2330,6 @@ packages:
'@vue/compiler-ssr@3.3.7':
resolution: {integrity: sha512-TxOfNVVeH3zgBc82kcUv+emNHo+vKnlRrkv8YvQU5+Y5LJGJwSNzcmLUoxD/dNzv0bhQ/F0s+InlgV0NrApJZg==}
- '@vue/compiler-ssr@3.5.13':
- resolution: {integrity: sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==}
-
'@vue/devtools-api@6.5.0':
resolution: {integrity: sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q==}
@@ -2359,21 +2350,12 @@ packages:
'@vue/reactivity@3.3.4':
resolution: {integrity: sha512-kLTDLwd0B1jG08NBF3R5rqULtv/f8x3rOFByTDz4J53ttIQEDmALqKqXY0J+XQeN0aV2FBxY8nJDf88yvOPAqQ==}
- '@vue/reactivity@3.5.13':
- resolution: {integrity: sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==}
-
'@vue/runtime-core@3.3.4':
resolution: {integrity: sha512-R+bqxMN6pWO7zGI4OMlmvePOdP2c93GsHFM/siJI7O2nxFRzj55pLwkpCedEY+bTMgp5miZ8CxfIZo3S+gFqvA==}
- '@vue/runtime-core@3.5.13':
- resolution: {integrity: sha512-Fj4YRQ3Az0WTZw1sFe+QDb0aXCerigEpw418pw1HBUKFtnQHWzwojaukAs2X/c9DQz4MQ4bsXTGlcpGxU/RCIw==}
-
'@vue/runtime-dom@3.3.4':
resolution: {integrity: sha512-Aj5bTJ3u5sFsUckRghsNjVTtxZQ1OyMWCr5dZRAPijF/0Vy4xEoRCwLyHXcj4D0UFbJ4lbx3gPTgg06K/GnPnQ==}
- '@vue/runtime-dom@3.5.13':
- resolution: {integrity: sha512-dLaj94s93NYLqjLiyFzVs9X6dWhTdAlEAciC3Moq7gzAc13VJUdCnjjRurNM6uTLFATRHexHCTu/Xp3eW6yoog==}
-
'@vue/server-renderer@3.3.4':
resolution: {integrity: sha512-Q6jDDzR23ViIb67v+vM1Dqntu+HUexQcsWKhhQa4ARVzxOY2HbC7QRW/ggkDBd5BU+uM1sV6XOAP0b216o34JQ==}
peerDependencies:
@@ -2384,11 +2366,6 @@ packages:
peerDependencies:
vue: 3.3.7
- '@vue/server-renderer@3.5.13':
- resolution: {integrity: sha512-wAi4IRJV/2SAW3htkTlB+dHeRmpTiVIK1OGLWV1yeStVSebSQQOwGwIq0D3ZIoBj2C2qpgz5+vX9iEBkTdk5YA==}
- peerDependencies:
- vue: 3.5.13
-
'@vue/shared@3.2.47':
resolution: {integrity: sha512-BHGyyGN3Q97EZx0taMQ+OLNuZcW3d37ZEVmEAyeoA9ERdGvm9Irc/0Fua8SNyOtV1w6BS4q25wbMzJujO9HIfQ==}
@@ -2398,9 +2375,6 @@ packages:
'@vue/shared@3.3.7':
resolution: {integrity: sha512-N/tbkINRUDExgcPTBvxNkvHGu504k8lzlNQRITVnm6YjOjwa4r0nnbd4Jb01sNpur5hAllyRJzSK5PvB9PPwRg==}
- '@vue/shared@3.5.13':
- resolution: {integrity: sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==}
-
'@vue/test-utils@2.3.2':
resolution: {integrity: sha512-hJnVaYhbrIm0yBS0+e1Y0Sj85cMyAi+PAbK4JHqMRUZ6S622Goa+G7QzkRSyvCteG8wop7tipuEbHoZo26wsSA==}
peerDependencies:
@@ -2434,8 +2408,10 @@ packages:
'@vueuse/shared@10.3.0':
resolution: {integrity: sha512-kGqCTEuFPMK4+fNWy6dUOiYmxGcUbtznMwBZLC1PubidF4VZY05B+Oht7Jh7/6x4VOWGpvu3R37WHi81cKpiqg==}
- '@vueuse/shared@12.0.0':
- resolution: {integrity: sha512-3i6qtcq2PIio5i/vVYidkkcgvmTjCqrf26u+Fd4LhnbBmIT6FN8y6q/GJERp8lfcB9zVEfjdV0Br0443qZuJpw==}
+ '@vueuse/shared@13.0.0':
+ resolution: {integrity: sha512-9MiHhAPw+sqCF/RLo8V6HsjRqEdNEWVpDLm2WBRW2G/kSQjb8X901sozXpSCaeLG0f7TEfMrT4XNaA5m1ez7Dg==}
+ peerDependencies:
+ vue: ^3.5.0
'@zhead/schema@1.0.0-beta.13':
resolution: {integrity: sha512-P1A1vRGFBhITco8Iw4/hvnDYoE/SoVrd71dW1pBFdXJb3vP+pBtoOuhbEKy0ROJGOyzQuqvFibcwzyLlWMqNiQ==}
@@ -2896,9 +2872,6 @@ packages:
csstype@3.1.2:
resolution: {integrity: sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==}
- csstype@3.1.3:
- resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
-
dash-get@1.0.2:
resolution: {integrity: sha512-4FbVrHDwfOASx7uQVxeiCTo7ggSdYZbqs8lH+WU6ViypPlDbe9y6IP5VVUDQBv9DcnyaiPT5XT0UWHgJ64zLeQ==}
@@ -4096,6 +4069,10 @@ packages:
resolution: {integrity: sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==}
engines: {node: '>=0.10.0'}
+ jsonrepair@3.12.0:
+ resolution: {integrity: sha512-SWfjz8SuQ0wZjwsxtSJ3Zy8vvLg6aO/kxcp9TWNPGwJKgTZVfhNEQBMk/vPOpYCDFWRxD6QWuI6IHR1t615f0w==}
+ hasBin: true
+
jwt-decode@3.1.2:
resolution: {integrity: sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==}
@@ -5701,14 +5678,6 @@ packages:
vue@3.3.4:
resolution: {integrity: sha512-VTyEYn3yvIeY1Py0WaYGZsXnz3y5UnGi62GjVEqvEGPl6nxbOrCXbVOTQWBEJUqAyTUk2uJ5JLVnYJ6ZzGbrSw==}
- vue@3.5.13:
- resolution: {integrity: sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==}
- peerDependencies:
- typescript: '*'
- peerDependenciesMeta:
- typescript:
- optional: true
-
vuedraggable@4.1.0:
resolution: {integrity: sha512-FU5HCWBmsf20GpP3eudURW3WdWTKIbEIQxh9/8GE806hydR9qZqRRxRE3RjqX7PkuLuMQG/A7n3cfj9rCEchww==}
peerDependencies:
@@ -6117,7 +6086,7 @@ snapshots:
'@babel/traverse': 7.23.2
'@babel/types': 7.23.0
convert-source-map: 2.0.0
- debug: 4.3.4
+ debug: 4.4.0
gensync: 1.0.0-beta.2
json5: 2.2.3
semver: 6.3.1
@@ -7030,7 +6999,7 @@ snapshots:
'@babel/helper-split-export-declaration': 7.22.6
'@babel/parser': 7.23.0
'@babel/types': 7.23.0
- debug: 4.3.4
+ debug: 4.4.0
globals: 11.12.0
transitivePeerDependencies:
- supports-color
@@ -7401,7 +7370,7 @@ snapshots:
'@linaria/logger@4.0.0':
dependencies:
- debug: 4.3.4
+ debug: 4.4.0
picocolors: 1.0.0
transitivePeerDependencies:
- supports-color
@@ -7922,7 +7891,7 @@ snapshots:
dependencies:
'@typescript-eslint/typescript-estree': 6.4.1(typescript@5.2.2)
'@typescript-eslint/utils': 6.4.1(eslint@8.47.0)(typescript@5.2.2)
- debug: 4.3.4
+ debug: 4.4.0
eslint: 8.47.0
ts-api-utils: 1.0.1(typescript@5.2.2)
optionalDependencies:
@@ -7940,10 +7909,10 @@ snapshots:
dependencies:
'@typescript-eslint/types': 5.60.0
'@typescript-eslint/visitor-keys': 5.60.0
- debug: 4.3.4
+ debug: 4.4.0
globby: 11.1.0
is-glob: 4.0.3
- semver: 7.5.4
+ semver: 7.6.3
tsutils: 3.21.0(typescript@5.2.2)
optionalDependencies:
typescript: 5.2.2
@@ -7968,10 +7937,10 @@ snapshots:
dependencies:
'@typescript-eslint/types': 6.9.1
'@typescript-eslint/visitor-keys': 6.9.1
- debug: 4.3.4
+ debug: 4.4.0
globby: 11.1.0
is-glob: 4.0.3
- semver: 7.5.4
+ semver: 7.6.3
ts-api-utils: 1.0.1(typescript@5.2.2)
optionalDependencies:
typescript: 5.2.2
@@ -7988,7 +7957,7 @@ snapshots:
'@typescript-eslint/typescript-estree': 5.60.0(typescript@5.2.2)
eslint: 8.47.0
eslint-scope: 5.1.1
- semver: 7.5.4
+ semver: 7.6.3
transitivePeerDependencies:
- supports-color
- typescript
@@ -8002,7 +7971,7 @@ snapshots:
'@typescript-eslint/types': 6.4.1
'@typescript-eslint/typescript-estree': 6.4.1(typescript@5.2.2)
eslint: 8.47.0
- semver: 7.5.4
+ semver: 7.6.3
transitivePeerDependencies:
- supports-color
- typescript
@@ -8016,7 +7985,7 @@ snapshots:
'@typescript-eslint/types': 6.9.1
'@typescript-eslint/typescript-estree': 6.9.1(typescript@5.2.2)
eslint: 8.47.0
- semver: 7.5.4
+ semver: 7.6.3
transitivePeerDependencies:
- supports-color
- typescript
@@ -8049,15 +8018,13 @@ snapshots:
dependencies:
'@unhead/schema': 0.5.1
- '@unhead/vue@0.5.1(typescript@5.2.2)(vue@3.3.4)':
+ '@unhead/vue@0.5.1(vue@3.3.4)':
dependencies:
'@unhead/dom': 0.5.1
'@unhead/schema': 0.5.1
- '@vueuse/shared': 12.0.0(typescript@5.2.2)
+ '@vueuse/shared': 13.0.0(vue@3.3.4)
unhead: 0.5.1
vue: 3.3.4
- transitivePeerDependencies:
- - typescript
'@unocss/astro@0.65.1(rollup@2.79.2)(vite@4.4.9(@types/node@18.15.11)(less@4.1.3)(terser@5.37.0))(vue@3.3.4)':
dependencies:
@@ -8341,14 +8308,6 @@ snapshots:
source-map-js: 1.0.2
optional: true
- '@vue/compiler-core@3.5.13':
- dependencies:
- '@babel/parser': 7.26.3
- '@vue/shared': 3.5.13
- entities: 4.5.0
- estree-walker: 2.0.2
- source-map-js: 1.2.1
-
'@vue/compiler-dom@3.2.47':
dependencies:
'@vue/compiler-core': 3.2.47
@@ -8365,11 +8324,6 @@ snapshots:
'@vue/shared': 3.3.7
optional: true
- '@vue/compiler-dom@3.5.13':
- dependencies:
- '@vue/compiler-core': 3.5.13
- '@vue/shared': 3.5.13
-
'@vue/compiler-sfc@3.2.47':
dependencies:
'@babel/parser': 7.21.4
@@ -8396,18 +8350,6 @@ snapshots:
postcss: 8.4.28
source-map-js: 1.0.2
- '@vue/compiler-sfc@3.5.13':
- dependencies:
- '@babel/parser': 7.26.3
- '@vue/compiler-core': 3.5.13
- '@vue/compiler-dom': 3.5.13
- '@vue/compiler-ssr': 3.5.13
- '@vue/shared': 3.5.13
- estree-walker: 2.0.2
- magic-string: 0.30.15
- postcss: 8.4.49
- source-map-js: 1.2.1
-
'@vue/compiler-ssr@3.2.47':
dependencies:
'@vue/compiler-dom': 3.2.47
@@ -8424,11 +8366,6 @@ snapshots:
'@vue/shared': 3.3.7
optional: true
- '@vue/compiler-ssr@3.5.13':
- dependencies:
- '@vue/compiler-dom': 3.5.13
- '@vue/shared': 3.5.13
-
'@vue/devtools-api@6.5.0': {}
'@vue/language-core@1.8.1(typescript@5.2.2)':
@@ -8464,33 +8401,17 @@ snapshots:
dependencies:
'@vue/shared': 3.3.4
- '@vue/reactivity@3.5.13':
- dependencies:
- '@vue/shared': 3.5.13
-
'@vue/runtime-core@3.3.4':
dependencies:
'@vue/reactivity': 3.3.4
'@vue/shared': 3.3.4
- '@vue/runtime-core@3.5.13':
- dependencies:
- '@vue/reactivity': 3.5.13
- '@vue/shared': 3.5.13
-
'@vue/runtime-dom@3.3.4':
dependencies:
'@vue/runtime-core': 3.3.4
'@vue/shared': 3.3.4
csstype: 3.1.2
- '@vue/runtime-dom@3.5.13':
- dependencies:
- '@vue/reactivity': 3.5.13
- '@vue/runtime-core': 3.5.13
- '@vue/shared': 3.5.13
- csstype: 3.1.3
-
'@vue/server-renderer@3.3.4(vue@3.3.4)':
dependencies:
'@vue/compiler-ssr': 3.3.4
@@ -8504,12 +8425,6 @@ snapshots:
vue: 3.3.4
optional: true
- '@vue/server-renderer@3.5.13(vue@3.5.13(typescript@5.2.2))':
- dependencies:
- '@vue/compiler-ssr': 3.5.13
- '@vue/shared': 3.5.13
- vue: 3.5.13(typescript@5.2.2)
-
'@vue/shared@3.2.47': {}
'@vue/shared@3.3.4': {}
@@ -8517,8 +8432,6 @@ snapshots:
'@vue/shared@3.3.7':
optional: true
- '@vue/shared@3.5.13': {}
-
'@vue/test-utils@2.3.2(vue@3.3.4)':
dependencies:
js-beautify: 1.14.6
@@ -8546,14 +8459,12 @@ snapshots:
- '@vue/composition-api'
- vue
- '@vueuse/head@1.0.0(typescript@5.2.2)(vue@3.3.4)':
+ '@vueuse/head@1.0.0(vue@3.3.4)':
dependencies:
'@unhead/schema': 0.5.1
'@unhead/ssr': 0.5.1
- '@unhead/vue': 0.5.1(typescript@5.2.2)(vue@3.3.4)
+ '@unhead/vue': 0.5.1(vue@3.3.4)
vue: 3.3.4
- transitivePeerDependencies:
- - typescript
'@vueuse/metadata@10.3.0': {}
@@ -8580,11 +8491,9 @@ snapshots:
- '@vue/composition-api'
- vue
- '@vueuse/shared@12.0.0(typescript@5.2.2)':
+ '@vueuse/shared@13.0.0(vue@3.3.4)':
dependencies:
- vue: 3.5.13(typescript@5.2.2)
- transitivePeerDependencies:
- - typescript
+ vue: 3.3.4
'@zhead/schema@1.0.0-beta.13': {}
@@ -9084,8 +8993,6 @@ snapshots:
csstype@3.1.2: {}
- csstype@3.1.3: {}
-
dash-get@1.0.2: {}
data-uri-to-buffer@4.0.1: {}
@@ -10412,6 +10319,8 @@ snapshots:
jsonpointer@5.0.1: {}
+ jsonrepair@3.12.0: {}
+
jwt-decode@3.1.2: {}
kind-of@6.0.3: {}
@@ -12018,7 +11927,7 @@ snapshots:
vite-node@0.34.0(@types/node@18.15.11)(less@4.1.3)(terser@5.37.0):
dependencies:
cac: 6.7.14
- debug: 4.3.4
+ debug: 4.4.0
mlly: 1.4.0
pathe: 1.1.1
picocolors: 1.0.0
@@ -12180,16 +12089,6 @@ snapshots:
'@vue/server-renderer': 3.3.4(vue@3.3.4)
'@vue/shared': 3.3.4
- vue@3.5.13(typescript@5.2.2):
- dependencies:
- '@vue/compiler-dom': 3.5.13
- '@vue/compiler-sfc': 3.5.13
- '@vue/runtime-dom': 3.5.13
- '@vue/server-renderer': 3.5.13(vue@3.5.13(typescript@5.2.2))
- '@vue/shared': 3.5.13
- optionalDependencies:
- typescript: 5.2.2
-
vuedraggable@4.1.0(vue@3.3.4):
dependencies:
sortablejs: 1.14.0
diff --git a/src/tools/json-viewer/json-viewer.vue b/src/tools/json-viewer/json-viewer.vue
index 3928a44f2..10be29c4b 100644
--- a/src/tools/json-viewer/json-viewer.vue
+++ b/src/tools/json-viewer/json-viewer.vue
@@ -1,26 +1,35 @@
@@ -33,6 +42,9 @@ const rawJsonValidation = useValidation({
+
+
+
diff --git a/src/tools/json-viewer/json.models.test.ts b/src/tools/json-viewer/json.models.test.ts
index 9bdcb231b..9ce1bb260 100644
--- a/src/tools/json-viewer/json.models.test.ts
+++ b/src/tools/json-viewer/json.models.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
-import { sortObjectKeys } from './json.models';
+import { formatJson, sortObjectKeys } from './json.models';
describe('json models', () => {
describe('sortObjectKeys', () => {
@@ -13,4 +13,19 @@ describe('json models', () => {
);
});
});
+
+ describe('formatJson', () => {
+ describe('repairJson', () => {
+ it('repairs and formats JSON when repairJson is true', () => {
+ const rawJson = '{"foo": "bar", "baz":}';
+ const result = formatJson({ rawJson, sortKeys: false, repairJson: true });
+ expect(result).to.equal(JSON.stringify({ foo: 'bar', baz: null }, null, 3));
+ });
+
+ it('throws an error for invalid JSON when repairJson is false', () => {
+ const rawJson = '{"foo": "bar", "baz":}';
+ expect(() => formatJson({ rawJson, sortKeys: false, repairJson: false })).to.throw();
+ });
+ });
+ });
});
diff --git a/src/tools/json-viewer/json.models.ts b/src/tools/json-viewer/json.models.ts
index 9bed3659b..ff5a8d346 100644
--- a/src/tools/json-viewer/json.models.ts
+++ b/src/tools/json-viewer/json.models.ts
@@ -1,5 +1,6 @@
import { type MaybeRef, get } from '@vueuse/core';
import JSON5 from 'json5';
+import { jsonrepair } from 'jsonrepair';
export { sortObjectKeys, formatJson };
@@ -24,12 +25,16 @@ function formatJson({
rawJson,
sortKeys = true,
indentSize = 3,
+ repairJson = false,
}: {
rawJson: MaybeRef
sortKeys?: MaybeRef
indentSize?: MaybeRef
+ repairJson?: MaybeRef
}) {
- const parsedObject = JSON5.parse(get(rawJson));
+ const unwrappedJson = get(rawJson);
+ const jsonString = get(repairJson) ? jsonrepair(unwrappedJson) : unwrappedJson;
+ const parsedObject = JSON5.parse(jsonString);
return JSON.stringify(get(sortKeys) ? sortObjectKeys(parsedObject) : parsedObject, null, get(indentSize));
}