Skip to content

Commit

Permalink
feat(json-to-csv) add example default value
Browse files Browse the repository at this point in the history
  • Loading branch information
gitmotion committed Oct 22, 2024
1 parent 5732483 commit 2dfe9c4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/tools/json-to-csv/json-to-csv.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 === '') {
Expand All @@ -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"
Expand Down

0 comments on commit 2dfe9c4

Please sign in to comment.