mirror of
https://github.com/CorentinTh/it-tools.git
synced 2024-12-25 09:12:54 +08:00
Merge 9b9594d4e8
into 08d977b8cd
This commit is contained in:
commit
e6ddaf08a7
1 changed files with 3 additions and 0 deletions
|
@ -4,6 +4,8 @@ import { convertArrayToCsv } from './json-to-csv.service';
|
|||
import type { UseValidationRule } from '@/composable/validation';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
|
||||
const defaultValue = '[\n {\n "Age": 18,\n "Country": "Germany",\n "Gender": "Male",\n "Purchased": "N",\n "Salary": 20000\n },\n {\n "Age": 19,\n "Country": "France",\n "Gender": "Female",\n "Purchased": "N",\n "Salary": 22000\n },\n {\n "Age": 20,\n "Country": "England",\n "Gender": "Female",\n "Purchased": "N",\n "Salary": 24000\n }\n]';
|
||||
|
||||
function transformer(value: string) {
|
||||
return withDefaultOnError(() => {
|
||||
if (value === '') {
|
||||
|
@ -24,6 +26,7 @@ const rules: UseValidationRule<string>[] = [
|
|||
<template>
|
||||
<format-transformer
|
||||
input-label="Your raw JSON"
|
||||
:input-default="defaultValue"
|
||||
input-placeholder="Paste your raw JSON here..."
|
||||
output-label="CSV version of your JSON"
|
||||
:input-validation-rules="rules"
|
||||
|
|
Loading…
Reference in a new issue