Last active
November 19, 2018 08:59
-
-
Save ValV/5c9bbd0a4e9bc9a380ca311353b2f371 to your computer and use it in GitHub Desktop.
test-serialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.github.valv.test</groupId> | |
<artifactId>test-serialization</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>com.github.valv.test test-serialization</name> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<kotlin.version>1.3.10</kotlin.version> | |
<serialization.version>0.9.0</serialization.version> | |
<kotlin.code.style>official</kotlin.code.style> | |
<junit.version>4.12</junit.version> | |
</properties> | |
<repositories> | |
<repository> | |
<id>bintray-kotlin-kotlinx</id> | |
<name>bintray</name> | |
<url>http://kotlin.bintray.com/kotlinx</url> | |
</repository> | |
</repositories> | |
<dependencies> | |
<dependency> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-stdlib</artifactId> | |
<version>${kotlin.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>org.jetbrains.kotlinx</groupId> | |
<artifactId>kotlinx-serialization-runtime</artifactId> | |
<version>0.9.0</version> | |
</dependency> | |
<dependency> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-reflect</artifactId> | |
<version>${kotlin.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-test-junit</artifactId> | |
<version>${kotlin.version}</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>${junit.version}</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<sourceDirectory>src/main/kotlin</sourceDirectory> | |
<testSourceDirectory>src/test/kotlin</testSourceDirectory> | |
<plugins> | |
<plugin> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlin-maven-plugin</artifactId> | |
<version>${kotlin.version}</version> | |
<executions> | |
<execution> | |
<id>compile</id> | |
<phase>compile</phase> | |
<goals> | |
<goal>compile</goal> | |
</goals> | |
</execution> | |
<execution> | |
<id>test-compile</id> | |
<phase>test-compile</phase> | |
<goals> | |
<goal>test-compile</goal> | |
</goals> | |
</execution> | |
</executions> | |
<configuration> | |
<compilerPlugins> | |
<plugin>kotlinx-serialization</plugin> | |
</compilerPlugins> | |
</configuration> | |
<dependencies> | |
<dependency> | |
<groupId>org.jetbrains.kotlin</groupId> | |
<artifactId>kotlinx-maven-serialization-plugin</artifactId> | |
<version>${kotlin.version}</version> | |
</dependency> | |
</dependencies> | |
</plugin> | |
<plugin> | |
<artifactId>maven-assembly-plugin</artifactId> | |
<version>3.1.0</version> | |
<configuration> | |
<descriptorRefs> | |
<descriptorRef>jar-with-dependencies</descriptorRef> | |
</descriptorRefs> | |
<archive> | |
<manifest> | |
<mainClass>com.github.valv.test.SerializingKt</mainClass> | |
</manifest> | |
</archive> | |
</configuration> | |
<executions> | |
<execution> | |
<id>make-assembly</id> | |
<phase>package</phase> | |
<goals> | |
<goal>single</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.valv.test | |
import kotlinx.serialization.* | |
import kotlinx.serialization.Serializable | |
import kotlinx.serialization.json.JSON | |
object Serializing { | |
@Serializable | |
data class SomeData(val name: String, val value: Any) | |
val serialData = SomeData.serializer().list | |
} | |
fun main(args: Array<String>) { | |
val someData = mutableListOf<Serializing.SomeData>() | |
someData.add(Serializing.SomeData("String", "")) | |
someData.add(Serializing.SomeData("Integer", 5)) | |
someData.add(Serializing.SomeData("Double", .7)) | |
println("Initial Data...") | |
println(someData) | |
println("Serialized Data...") | |
println(JSON().stringify(Serializing.serialData, someData)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment