Skip to content

Commit

Permalink
Merge pull request #4 from sunnydanu/feat(json-to-csv)-add-example-de…
Browse files Browse the repository at this point in the history
…fault-value

feat(json-to-csv)-add-example-default-value
  • Loading branch information
sunnydanu authored Nov 2, 2024
2 parents 47d58c8 + 1eb0b04 commit 60113e9
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 60113e9

Please sign in to comment.