Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunolike committed Aug 3, 2024
2 parents 55280e3 + 84ec57c commit ff4f06a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 예제 샘프 ###
examples/
examples/spring-boot-kotlin/.idea/



### intellij ###
*.iml
.idea/
Expand Down
27 changes: 0 additions & 27 deletions HELP.md

This file was deleted.

8 changes: 6 additions & 2 deletions examples/spring-boot-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ java {
languageVersion = JavaLanguageVersion.of(21)
}
}

repositories {
mavenCentral()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}

dependencies {
// 오픈소스 프로젝트 추가
// Add open-source project
implementation("com.github.hyunolike:json-csv-bridge:v0.0.3")

implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
package com.example

import com.jsoncsvbridge.factory.DefaultCsvCreatorFactory
import org.springframework.boot.CommandLineRunner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.stereotype.Component
import java.io.File

@SpringBootApplication
class SpringBootKotlinApplication

fun main(args: Array<String>) {
runApplication<SpringBootKotlinApplication>(*args)
runApplication<SpringBootKotlinApplication>(*args)
}

@Component
class CsvCreatorRunner() : CommandLineRunner {
override fun run(vararg args: String) {
val outputDir = File("csv_output").apply { mkdirs() }

// JSON to CSV
val jsonCreator = DefaultCsvCreatorFactory().createCsvCreator("json");
val jsonOutputPath = outputDir.resolve("output_json.csv").absolutePath

// JSON to CSV
val jsonInput = """
[
{"name": "Alice", "age": 30, "city": "New York"},
{"name": "Bob", "age": 25, "city": "Los Angeles"},
{"name": "Charlie", "age": 35, "city": "Chicago"}
]
"""

jsonCreator.createCsv(jsonInput, jsonOutputPath)
println("JSON to CSV conversion completed. File saved at: $jsonOutputPath")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ class DefaultCsvCreatorFactory : CsvCreatorFactory {
else -> throw IllegalArgumentException("Unknown type")
}
}

companion object {
@JvmStatic
fun createCsvCreator(type: String): CsvCreator {
return DefaultCsvCreatorFactory().createCsvCreator(type)
}
}
}

0 comments on commit ff4f06a

Please sign in to comment.