File tree Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
6
6
7
7
import { tool as textToUnicode } from './text-to-unicode' ;
8
8
import { tool as safelinkDecoder } from './safelink-decoder' ;
9
+ import { tool as jsonLinter } from './json-linter' ;
9
10
import { tool as pdfSignatureChecker } from './pdf-signature-checker' ;
10
11
import { tool as numeronymGenerator } from './numeronym-generator' ;
11
12
import { tool as macAddressGenerator } from './mac-address-generator' ;
@@ -142,6 +143,7 @@ export const toolsByCategory: ToolCategory[] = [
142
143
crontabGenerator ,
143
144
jsonViewer ,
144
145
jsonMinify ,
146
+ jsonLinter ,
145
147
jsonToCsv ,
146
148
sqlPrettify ,
147
149
chmodCalculator ,
Original file line number Diff line number Diff line change
1
+ import { ArrowsShuffle } from '@vicons/tabler' ;
2
+ import { defineTool } from '../tool' ;
3
+
4
+ export const tool = defineTool ( {
5
+ name : 'Json linter' ,
6
+ path : '/json-linter' ,
7
+ description : '' ,
8
+ keywords : [ 'json' , 'linter' ] ,
9
+ component : ( ) => import ( './json-linter.vue' ) ,
10
+ icon : ArrowsShuffle ,
11
+ createdAt : new Date ( '2024-03-27' ) ,
12
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script setup lang="ts">
2
+ import linter from ' jsonlint-mod' ;
3
+
4
+ const jsonContent = ref (
5
+ ` {
6
+ a: True;
7
+ b=5
8
+ } ` ,
9
+ );
10
+
11
+ const conversionResult = computed (() => {
12
+ try {
13
+ linter .parse (jsonContent .value );
14
+ return JSON .stringify (JSON .parse (jsonContent .value ), null , 2 );
15
+ }
16
+ catch (e : any ) {
17
+ return e .toString ().split (' \n ' ).map ((err : string ) => ({ line: - 1 , message: err , helpLink: ' ' }));
18
+ }
19
+ });
20
+
21
+ const errors = computed (() => conversionResult .value );
22
+
23
+ const MONACO_EDITOR_OPTIONS = {
24
+ automaticLayout: true ,
25
+ formatOnType: true ,
26
+ formatOnPaste: true ,
27
+ };
28
+ </script >
29
+
30
+ <template >
31
+ <div >
32
+ <c-label label =" Paste your JSON file content:" >
33
+ <div relative w-full >
34
+ <c-monaco-editor
35
+ v-model:value =" jsonContent"
36
+ theme =" vs-dark"
37
+ language =" yaml"
38
+ height =" 250px"
39
+ :options =" MONACO_EDITOR_OPTIONS"
40
+ />
41
+ </div >
42
+ </c-label >
43
+
44
+ <div v-if =" errors.length > 0" >
45
+ <n-alert title =" The following errors occured" type =" error" mt-5 >
46
+ <ul >
47
+ <li v-for =" (message, index) of errors" :key =" index" >
48
+ {{ message.message }} (<n-a v-if =" message.helpLink" target =" _blank" rel =" noreferer noopener" >
49
+ See JSON help
50
+ </n-a >)
51
+ </li >
52
+ </ul >
53
+ </n-alert >
54
+ </div >
55
+ <div v-else >
56
+ <n-alert type =" success" mt-5 >
57
+ Validation successful!
58
+ </n-alert >
59
+ </div >
60
+ </div >
61
+ </template >
You can’t perform that action at this time.
0 commit comments