Add json minifier tool

This commit is contained in:
Illya Marchenko 2024-09-19 11:58:34 +03:00
parent e99e92dda4
commit ee930f96fc
Signed by: stuzer05
GPG Key ID: A6ABAAA9268F9F4F
3 changed files with 57 additions and 0 deletions

View File

@ -67,6 +67,7 @@ export default {
// 'sql_tables_to_struct': 'SQL tables Go struct',
},
'JSON': {
'json_minifier': 'JSON minifier',
'json_formatter': 'JSON formatter',
},
'SQL': {

View File

@ -129,6 +129,11 @@ const router = createRouter({
name: 'json_formatter',
component: () => import('../views/JSONFormatter.vue'),
},
{
path: '/json_minifier',
name: 'json_minifier',
component: () => import('../views/JSONMinifier.vue'),
},
/**
* Golang

View File

@ -0,0 +1,51 @@
<template>
<h2 class="tool-title">JSON Minifier</h2>
<hr class="mt-5 mb-5">
<div class="input-group">
<label for="data">Data</label>
<textarea id="data" v-model="toolData.data" v-on:keyup="minify"></textarea>
</div>
<hr class="mt-5 mb-5">
<div class="input-group">
<label for="result">Result</label>
<MonacoEditor name="result" language="json" :value="toolResult"></MonacoEditor>
</div>
</template>
<script>
import MonacoEditor from "@/components/MonacoEditor.vue";
export default {
components: {
MonacoEditor
},
data() {
return {
toolData: {
data: '',
},
toolResult: '',
};
},
methods: {
minify() {
if (!this.toolData.data.length) {
this.toolResult = '';
} else {
try {
this.toolResult = JSON.stringify(JSON.parse(this.toolData.data));
} catch (e) {
this.toolResult = 'invalid syntax';
}
}
}
},
}
</script>
<style lang="scss">
</style>