commit | ed87fbd364d2e5dfce15de0a80a3b48da26cdf0f | [log] [tgz] |
---|---|---|
author | Leonid Startsev <sandwwraith@gmail.com> | Fri Aug 04 17:33:09 2017 +0300 |
committer | Leonid Startsev <sandwwraith@gmail.com> | Fri Aug 04 17:33:09 2017 +0300 |
tree | b6747f5ea60e6fae3b27cb0a0e9e3bd4b8c97910 | |
parent | c345b20f33a1fb9c84b70665c0d25168643e9934 [diff] |
Protobuf tests based on Google protobuf library Small random testing framework Protobuf fixes
Kotlin serialization plugin consists of three parts: a gradle compiler plugin, an IntelliJ plugin and a runtime library. This is the runtime library. To build any project with serialization (including this one), you'll need a serialization gradle plugin. To have a proper syntax highlighting in the Intellij IDEA, you'll need an IDEA plugin.
Runtime library provides basic classes:
Interfaces which are called by compiler-generated code (KInput
, KOutput
)
Basic skeleton implementations of these interfaces in which you should override some methods if you want to implement custom data format (ElementValueInput/Output
, NamedValueInput/Output
, ElementValueTransformer
)
Some internal classes like built-ins and collections serializers
Also, runtime library provides some ready-to-use serialization formats: JSON and CBOR.
Make sure you have serialization gradle plugin installed to your local maven repository. Then, run ./gradlew publishToMavenLocal
. After that, you can include this library in arbitrary projects like usual gradle dependency:
repositories { jcenter() mavenLocal() } dependencies { compile "org.jetbrains.kotlinx:serialization-runtime:1.1-SNAPSHOT" }
import kotlinx.serialization.* @Serializable data class Data(val a: Int, @Optional val b: String = "42") fun main(args: Array<String>) { println(JSON.stringify(Data(42))) // {"a": 42, "b": "42"} val obj = JSON.parse<Data>("""{"a":42}""") // Data(a=42, b="42") }
More complicated examples and examples of implementing custom formats can be found in examples
folder. Detailed documentation located in DOC.md.