All Projects → esensar → kotlinx-serialization-msgpack

esensar / kotlinx-serialization-msgpack

Licence: MIT License
MsgPack support for kotlinx.serialization -- msgpack.org[kotlinx.serialization]

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to kotlinx-serialization-msgpack

Json
JSON for Modern C++
Stars: ✭ 27,824 (+163570.59%)
Mutual labels:  msgpack, messagepack
R6rs Msgpack
MessagePack for R6RS Scheme / msgpack.org[Scheme]
Stars: ✭ 14 (-17.65%)
Mutual labels:  msgpack, messagepack
Msgpack Rust
MessagePack implementation for Rust / msgpack.org[Rust]
Stars: ✭ 561 (+3200%)
Mutual labels:  msgpack, messagepack
Messagepack Csharp
Extremely Fast MessagePack Serializer for C#(.NET, .NET Core, Unity, Xamarin). / msgpack.org[C#]
Stars: ✭ 3,668 (+21476.47%)
Mutual labels:  msgpack, messagepack
sbp
Structured Bindings Pack - serialize C++ structs into MessagePack binary form
Stars: ✭ 16 (-5.88%)
Mutual labels:  msgpack, messagepack
Remarshal
Convert between CBOR, JSON, MessagePack, TOML, and YAML
Stars: ✭ 421 (+2376.47%)
Mutual labels:  msgpack, messagepack
Msgpack Cli
MessagePack implementation for Common Language Infrastructure / msgpack.org[C#]
Stars: ✭ 761 (+4376.47%)
Mutual labels:  msgpack, messagepack
Msgpack.php
A pure PHP implementation of the MessagePack serialization format / msgpack.org[PHP]
Stars: ✭ 327 (+1823.53%)
Mutual labels:  msgpack, messagepack
rcppmsgpack
MsgPack Headers for R / msgpack.org[R]
Stars: ✭ 17 (+0%)
Mutual labels:  msgpack, messagepack
msgpack-perl
MessagePack serializer implementation for Perl / msgpack.org[Perl]
Stars: ✭ 48 (+182.35%)
Mutual labels:  msgpack, messagepack
Mpack
MPack - A C encoder/decoder for the MessagePack serialization format / msgpack.org[C]
Stars: ✭ 282 (+1558.82%)
Mutual labels:  msgpack, messagepack
msgpack-asgi
Drop-in MessagePack support for ASGI applications and frameworks
Stars: ✭ 100 (+488.24%)
Mutual labels:  msgpack, messagepack
Msgpack Javascript
MessagePack for JavaScript/TypeScript/ECMA-262 / msgpack.org[JavaScript]
Stars: ✭ 742 (+4264.71%)
Mutual labels:  msgpack, messagepack
Msgpack11
A tiny MessagePack library for C++11 (msgpack.org[C++11])
Stars: ✭ 78 (+358.82%)
Mutual labels:  msgpack, messagepack
what-the-pack
Ultra-fast MessagePack for NodeJS & Browsers | msgpack.org[Javascript/NodeJS]
Stars: ✭ 36 (+111.76%)
Mutual labels:  msgpack, messagepack
KotlinMultiplatformAndoridParcelize
Use the Parcelize Annotation of the Kotlin Android Extensions in Kotin Multiplatform projects
Stars: ✭ 16 (-5.88%)
Mutual labels:  kotlin-native, kotlin-serialization
Java-Memory-Manipulation
User friendly, Garbage-free, and cross-platform process, module and memory interfacing via the power of Java
Stars: ✭ 51 (+200%)
Mutual labels:  native
SPStorkController
Now playing controller from Apple Music, Mail & Podcasts Apple's apps.
Stars: ✭ 2,515 (+14694.12%)
Mutual labels:  native
moko-errors
Automated exceptions handler for mobile (android & ios) Kotlin Multiplatform development.
Stars: ✭ 45 (+164.71%)
Mutual labels:  kotlin-native
webviewhs
🌐 A Haskell binding to the webview library created by Serge Zaitsev.
Stars: ✭ 109 (+541.18%)
Mutual labels:  native

kotlinx-serialization-msgpack

Tests javadoc Maven Central Sonatype Nexus (Snapshots)

Project is under active development! Important features may be missing and bugs are present!

Check out milestones for progress.

About

This library provides MsgPack support for kotlinx.serialization. It supports all of kotlin targets (JVM, JS, Native).

Integration

Maven central

Gradle:

implementation("com.ensarsarajcic.kotlinx:serialization-msgpack:${kotlinxSerializationMsgPackVersion}")

To also use timestamp support with kotlinx-datetime, use serialization-msgpack-timestamp-extension:

implementation("com.ensarsarajcic.kotlinx:serialization-msgpack-timestamp-extension:${kotlinxSerializationMsgPackVersion}")

NOTE: Timestamp support is available in core library as well, the additional library just adds a specific serializer that can be used with kotlinx-datetime types. These are MsgPackTimestamp32DatetimeSerializer, MsgPackTimestamp64DatetimeSerializer and MsgPackTimestamp96DatetimeSerializer.

For experimental kotlin unsigned types support, use serialization-msgpack-unsigned-support:

implementation("com.ensarsarajcic.kotlinx:serialization-msgpack-unsigned-support:${kotlinxSerializationMsgPackVersion}")

Snapshot builds

Gradle:

repositories {
    maven {
        url = uri("https://oss.sonatype.org/content/repositories/snapshots")
    }
}
implementation("com.ensarsarajcic.kotlinx:serialization-msgpack:${kotlinxSerializationMsgPackSnapshotVersion}")

To also use timestamp support with kotlinx-datetime, use serialization-msgpack-timestamp-extension:

implementation("com.ensarsarajcic.kotlinx:serialization-msgpack-timestamp-extension:${kotlinxSerializationMsgPackSnapshotVersion}")

For experimental kotlin unsigned types support, use serialization-msgpack-unsigned-support:

implementation("com.ensarsarajcic.kotlinx:serialization-msgpack-unsigned-support:${kotlinxSerializationMsgPackSnapshotVersion}")

Usage

Library should be used in same way as any other kotlinx.serialization library. Created models are annotated with @Serializable annotation and their serializer() can be passed to MsgPack.

Example:

@Serializable
data class SampleClass(
    val testString: String,
    val testInt: Int,
    val testBoolean: Boolean
)

fun encode() {
    println(
        MsgPack.encodeToByteArray(
            SampleClass.serializer(),
            SampleClass("def", 123, true)
        ).joinToString(separator = "") { it.toInt().and(0xff).toString(16).padStart(2, '0') }
    ) // Outputs: 83aa74657374537472696e67a3646566a774657374496e747bab74657374426f6f6c65616ec3
}

fun decode() {
    println(
        MsgPack.decodeFromByteArray(
            SampleClass.serializer(),
            "83aa74657374537472696e67a3646566a774657374496e747bab74657374426f6f6c65616ec3".let { bytesString ->
                ByteArray(bytesString.length / 2) { bytesString.substring(it * 2, it * 2 + 2).toInt(16).toByte() }
            }
        )
    ) // Outputs: SampleClass(testString=def, testInt=123, testBoolean=true)
}

Contributing

Check out contributing guidelines.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].