Added json-stringify
updated to json.stringify fixing quick error
This commit is contained in:
		
							parent
							
								
									f962c416a3
								
							
						
					
					
						commit
						4ade39054c
					
				| @ -332,6 +332,10 @@ tools: | ||||
|     title: JSON minify | ||||
|     description: Minify and compress your JSON by removing unnecessary whitespace. | ||||
| 
 | ||||
|   json-stringify: | ||||
|     title: JSON Stringify | ||||
|     description: Convert your plain text or JavaScript objects into a JSON string format by escaping special characters and ensuring valid JSON structure. Ideal for transmitting data or storing in JSON-compatible formats. | ||||
| 
 | ||||
|   ulid-generator: | ||||
|     title: ULID generator | ||||
|     description: Generate random Universally Unique Lexicographically Sortable Identifier (ULID). | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| import { tool as base64FileConverter } from './base64-file-converter'; | ||||
| import { tool as base64StringConverter } from './base64-string-converter'; | ||||
| import { tool as basicAuthGenerator } from './basic-auth-generator'; | ||||
| import { tool as jsonStringify } from './json-stringify'; | ||||
| import { tool as emailNormalizer } from './email-normalizer'; | ||||
| 
 | ||||
| import { tool as asciiTextDrawer } from './ascii-text-drawer'; | ||||
| @ -151,6 +152,7 @@ export const toolsByCategory: ToolCategory[] = [ | ||||
|       crontabGenerator, | ||||
|       jsonViewer, | ||||
|       jsonMinify, | ||||
|       jsonStringify, | ||||
|       jsonToCsv, | ||||
|       sqlPrettify, | ||||
|       chmodCalculator, | ||||
|  | ||||
							
								
								
									
										12
									
								
								src/tools/json-stringify/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/tools/json-stringify/index.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | ||||
| import { ClearFormatting } from '@vicons/tabler'; | ||||
| import { defineTool } from '../tool'; | ||||
| 
 | ||||
| export const tool = defineTool({ | ||||
|   name: 'Json stringify', | ||||
|   path: '/json-stringify', | ||||
|   description: '', | ||||
|   keywords: ['json', 'stringify'], | ||||
|   component: () => import('./json-stringify.vue'), | ||||
|   icon: ClearFormatting, | ||||
|   createdAt: new Date('2024-10-17'), | ||||
| }); | ||||
							
								
								
									
										26
									
								
								src/tools/json-stringify/json-stringify.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/tools/json-stringify/json-stringify.vue
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| <script setup lang="ts"> | ||||
| import type { UseValidationRule } from '@/composable/validation'; | ||||
| import { withDefaultOnError } from '@/utils/defaults'; | ||||
| 
 | ||||
| const defaultValue = '{\n\t"hello": [\n\t\t"world"\n\t]\n}'; | ||||
| const transformer = (value: string) => withDefaultOnError(() => JSON.stringify(value), ''); | ||||
| 
 | ||||
| const rules: UseValidationRule<string>[] = [ | ||||
|   { | ||||
|     validator: (v: string) => v === '' || JSON.stringify(v), | ||||
|     message: 'Provided text is not valid.', | ||||
|   }, | ||||
| ]; | ||||
| </script> | ||||
| 
 | ||||
| <template> | ||||
|   <format-transformer | ||||
|     input-label="Your string / text" | ||||
|     :input-default="defaultValue" | ||||
|     input-placeholder="Paste your text here..." | ||||
|     output-label="JSON stringified version of your string" | ||||
|     output-language="json" | ||||
|     :input-validation-rules="rules" | ||||
|     :transformer="transformer" | ||||
|   /> | ||||
| </template> | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user