random-web-tools/src/views/json/JSONMinifier.vue

51 lines
999 B
Vue
Raw Normal View History

2024-09-19 11:58:34 +03:00
<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: {
2024-09-28 15:16:10 +03:00
data: ""
2024-09-19 11:58:34 +03:00
},
2024-09-28 15:16:10 +03:00
toolResult: ""
2024-09-19 11:58:34 +03:00
};
},
methods: {
minify() {
if (!this.toolData.data.length) {
2024-09-28 15:16:10 +03:00
this.toolResult = "";
2024-09-19 11:58:34 +03:00
} else {
try {
this.toolResult = JSON.stringify(JSON.parse(this.toolData.data));
} catch (e) {
2024-09-28 15:16:10 +03:00
this.toolResult = "invalid syntax";
2024-09-19 11:58:34 +03:00
}
}
}
2024-09-28 15:16:10 +03:00
}
};
2024-09-19 11:58:34 +03:00
</script>
<style lang="scss">
</style>