Popularity
1.7
Declining
Activity
5.4
-
55
3
2

Description

Android Bundle format support for Kotlinx Serialization.

Programming language: Kotlin
License: Apache License 2.0
Tags: Kotlin     Android     Android-library     Serialization     Bundles    
Latest version: v0.4.0

Bundlizer alternatives and similar packages

Based on the "Kotlin" category.
Alternatively, view Bundlizer alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Bundlizer or a related project?

Add another 'Kotlin' Package

README

Bundlizer CI Maven Central

Android Bundle format support for Kotlinx Serialization.

Usage

Annotate your data models with @Serializable:

import kotlinx.serialization.Serializable

enum class Type {
    HUMAN, MONKEY
}

@Serializable
data class Email(val value: String)

@Serializable
data class User(
    val id: Int,
    val name: String,
    val email: Email,
    val friends: List<String>?,
    val something: Map<String, Int>,
    val type: Type
)

To Bundle

Use Bundlizer.bundle or bundle extension function:

import dev.ahmedmourad.bundlizer.Bundlizer
import dev.ahmedmourad.bundlizer.bundle
import android.os.Bundle

val user: User = ...

val bundle: Bundle = Bundlizer.bundle(User.serializer(), user)
// or
val bundle: Bundle = user.bundle(User.serializer())

From Bundle

Use Bundlizer.unbundle or unbundle extension function:

import dev.ahmedmourad.bundlizer.Bundlizer
import dev.ahmedmourad.bundlizer.unbundle
import android.os.Bundle

val bundle: Bundle = ...

val user: User = Bundlizer.unbundle(User.serializer(), bundle)
// or
val user: User = bundle.unbundle(User.serializer())

Installation

  • Add kotlinx.serialization to your project.

  • In your module-level build.gradle:

    repositories {
    mavenCentral()
    }
    

dependencies { implementation "dev.ahmedmourad.bundlizer:bundlizer-core:0.3.0" }


License
-------

    Copyright (C) 2020 Ahmed Mourad

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.




*Note that all licence references and agreements mentioned in the Bundlizer README section above are relevant to that project's source code only.