feat(JSON Escaper): option Wrap in quotes

This commit is contained in:
ShareVB committed 2025-08-21 15:18:00 +02:00
1 parent 8ee06eeedb
commit e2f6a8299c
2 files changed
+15 -3

No files matched your search

+1
View File
@@ -2355,6 +2355,7 @@ tools:
placeholder-put-your-string-to-unescape: Put your string to unescape...
label-string-to-unescape: String to unescape
label-unescaped-string: Unescaped string
label-wrap-in-quotes: Wrap in quotes
json-linter:
title: JSON Linter
description: Check and lint JSON content
+14 -3
View File
@@ -2,15 +2,20 @@
import { useI18n } from 'vue-i18n';
import { addSlashes, removeSlashes } from 'slashes';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useQueryParam } from '@/composable/queryParams';
import { useQueryParam, useQueryParamOrStorage } from '@/composable/queryParams';
const { t } = useI18n();
const wrapInQuotes = useQueryParamOrStorage({ name: 'wrap', storageName: 'json-escaper:wrap', defaultValue: false });
const unescapedInput = useQueryParam({ tool: 'json-escaper', name: 'escape', defaultValue: '' });
const escapedOutput = computed(
() => {
try {
return addSlashes(unescapedInput.value);
const slashedString = addSlashes(unescapedInput.value);
if (wrapInQuotes.value) {
return `"${slashedString}"`;
}
return slashedString;
}
catch (e: any) {
return e.toString();
@@ -41,9 +46,15 @@ const unescapedOutput = computed(
raw-text
multiline
rows="5"
mb-5
mb-1
/>
<n-space justify="center">
<n-form-item mb-5 label-placement="left" :label="t('tools.json-escaper.texts.label-wrap-in-quotes')">
<n-checkbox v-model:checked="wrapInQuotes" />
</n-form-item>
</n-space>
<n-divider />
<TextareaCopyable