Skip to content

Instantly share code, notes, and snippets.

@ejektaflex
Created January 12, 2018 05:18
Show Gist options
  • Save ejektaflex/66b2cd09be90bfb1977a293580f411d3 to your computer and use it in GitHub Desktop.
Save ejektaflex/66b2cd09be90bfb1977a293580f411d3 to your computer and use it in GitHub Desktop.
buildscript {
ext.kotlin_version = '1.2.10'
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
sourceCompatibility = 1.8
repositories {
jcenter()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
// Errors on Klaxon 2.0.3 as well
compile 'com.beust:klaxon:2.0.5'
}
import com.beust.klaxon.Klaxon
import data.StockEntry
import java.io.File
fun main(args: Array<String>) {
val stockFile = File("src/main/kotlin/data/STOCK.json").inputStream()
val data = Klaxon().parseArray<StockEntry>(stockFile)
println(data)
}
package data
data class StockEntry(
val date: String,
val close: Double,
val volume: Int,
val open: Double,
val high: Double,
val low: Double
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment